Tuesday, June 25, 2013

Activity 5 - Area Estimation

We started this activity last Thursday and we were allotted two meeting for it. The activity was a bit tedious but is easy once you get the hang of it. Scilab, GIMP and even Microsoft Paint (for my case at least) were utilized in this activity.

To start, the task is to estimate the area of a certain figure in an image. As a start, we were asked to create black and white pictures of regular polygons. I created five - rectangle, square, circle, equilateral triangle and right triangle - using Paint, as it was the easiest method for me. The background was black, and the shapes were white. Also, the area of the shapes should be analytically known. For my case, I measured the pixel dimensions to obtain the area.

Next, I loaded the image in Scilab and obtained the edge image as asked in the activity. Before running the script I made, however, I typed in help edge on the console to know more about the command. I found out that there are five ways that Scilab calculates for the edges. I used all five methods and compared the results.

So here are my results. First I used the rectangle. I measured the length and width of the figure to be 119 and 449 pixels, respectively, and so the area of the rectangle is 53,431 square pixels (sq. px.).
Figure 1.  A rectangle, with an area of
53,341 sq. px.

Then I used all five methods to obtain the edges, and ultimately the area, of the rectangle. First, I used the Sobel gradient estimation method, which uses a pair of 3x3 convolution masks to estimate the gradient along the rows and the columns of a 2x2 matrix (in our case an image) [1]. The result is shown below.
Figure 2. Obtaining the edges of the
rectangle using the Sobel method.
e = edge(im, 'sobel');

Wednesday, June 19, 2013

Activity 4 - Image Types and Formats

Yesterday's activity was about the different image types and formats used in image processing. The first task was to obtain a true color image and manipulate it by converting the image into grayscale, binary and indexed forms. For this part, I used GNU Image Manipulation Program (GIMP) and obtained true color images of beautiful landscapes online.

This is the image that I chose, scaled down to 25% for web viewing, which I obtained here. The original size is 1280 x 1024 pixels and the resolution is 72 x 72 pixels per inch (ppi). Also, the image file size is 404 kB. After rescaling, however, the new image size, resolution and file size is 320 x 256 pixels, 72 pixels per inch and 58.0 kB. The next three images show the grayscale, binary and indexed forms of the original, true color image.


Clockwise from top left: (a) rescaled image in true color, 58.0 kB; (b) image converted
into grayscale, 49.8 kB; (c) image converted into binary, 4.76 kB; and (d) indexed image
with 32 values, 25.7 kB.

Thursday, June 13, 2013

Activity 3 - Scilab Basics

Today's activity involved getting familiar with Scilab, an open source programming software similar in functionality with Matlab. First I tried to discover some basic commands in Scilab (as I usually do when learning a new programming language) before diving deeper. When I felt that I was ready enough, I tried to do the exercises

To start, I copied Ma'am Jing's example to create a circular pattern:
nx = 100; ny = 100; //defines the number of
elements along x and y
x = linspace(-1,1,nx); //defines the range
y = linspace(-1,1,ny);
[X,Y] = ndgrid(x,y); //creates two 2-D arrays of x
and y coordinates
r= sqrt(X.^2 + Y.^2); //note element-per-element
squaring of X and Y
A = zeros (nx,ny);
A (find(r<0.7) ) = 1;
f = scf();
grayplot(x,y,A);
f.color_map = graycolormap(32);
 The result was this:

The edges are a bit rough because the sample size (nx, ny) is small. If we increase this to, say 500, the edges will be smoother.

Tuesday, June 11, 2013

Activity 2 - Digital Scanning

For today's activity, we first obtained a scanned image of a handwritten plot. I took mine from a paper from the Proceedings of the 4th National Physics Congress, 1985 (exact paper and authors to follow!). The task is to reproduce the plot by obtaining the conversion factor between the number of pixels in the scanned image to the physical variable that the plot represents.

The plot I chose shows the graph of impulse squared (in million K/m^2) versus the distance (in cm) of a glider that moves in an airtrack before colliding with a bumper. The exact methodology is described in the paper. The graph is supposed to reflect the relationship of energy, impulse and momentum.