Thursday, June 26, 2008

Activity 3

PART 1. 4 Basic Image Types

image 1 (original image)



image 2 (binary image)

image 3 (greyscale image)


image 4 (indexed image)


image 1 image 2 image 3 image 4 not shown
FileSize 123232 38462 36422 68111 303780
Format JPEG BMP JPEG GIF PNG
Width 640 640 640 640 640
Height 480 480 480 480 480
Depth 24 1 8 8 24
StorageType truecolor indexed greyscale indexed truecolor
NumberOfColors 0 2 256 256 0

//i converted the same image (a beautifully 3D rendered glass heart by bryan shane oney) into binary, grayscale, and indexed images. Scilab returned zero for the number of colors for both truecolor images, i did not upload the PNG image because it looked exactly like the original JPEG image, the larger file size of the former was as discussed in class, due to the success of the compression of *.jpg images. Also, *.gif images are indexed by default and as we see here, though it is colored, the file size is considerably smaller than the other colored images. The indexing/compression of GIF files seem a little buggy though because upon closer inspection, it undermines the quality of the image.



PART 2. Basic Image Enhancement


The original image:
FileSize 38200
Format PNG
Width 400
Height 444
Depth 8
StorageType grayscale
NumberOfColors 256

\\of course to be able to find the area of the object i had to crop away the rulers using Corel PhotoPaint 12, the same program i used to place the vertical ruler in the picture in the first place.
Cropped Image:\\the contrast is already obviously quite good in this picture, and according to its histogram:
\\histogram obtained using the following Scilab Code provided by jeric tugaff:

im=imread('C:\Documents and Settings\Endura\My Documents\1863.jpg');
getf('imhist.sce');

[val, num]=imhist(im);
plot(val, num);

\\it was then converted to black and white (through thresholding with the threshold value inferred from the histogram plot values) and then inverted.

imb=im2bw(im,0.8);
imb=abs(1-imb);

\\the same methods (and code) from the last activity were then used to find the area of the object from this last inverted black and white picture.

[a,b] = follow(imb);
i = [1:760]; //index
a(i) = abs((x(i).*y(i+1))-(y(i).*x(i+1)))/2;
a(761) = abs((x(761)*y(1))-(y(761)*x(1)))/2;
sum(a)

***The 10-line code returned an area value of 51848.5 pixel units squared.

***I give myself a grade of 8 for this activity because my attempts at making the code work by myself kept failing because of little things that made a lot of difference and eventually gave in and used jeric's suggested codes. Also, since my object has a *very* irregular shape, i could not find a way to measure its "real" area to compare with the result of the code.

***thank you to cole fabros and jeric tugaff for being huge helps in this activity

Thursday, June 19, 2008

Activity 2

Area Estimation of Images with Defined Edges (Regular Shapes)


*I used Scilab and its SIP toolbox to measure the areas of a circle, a rectangle and a square i have drawn using MS Paint.

The sample code used for the activity (square) is as follows:


-->[sqim] = imread ('C:\Documents and Settings\AP186user07\My Documents\My Pictures\sq.bmp'); //reads the binary image of a square

-->[x,y] = follow(sqim); //extracts parametric contours of the object and stores them as x and y vectors

-->length(x) //gives the length of array x which is the same as that of array y (returned 392)

-->
i = [1:391]; //index

-->
a(i) = ((x(i).*y(i+1))-(y(i).*x(i+1)))/2 //returns array of the areas of the pie-shaped finite partition

-->a(392) = ((x(392)*y(1))-(y(392)*x(1)))/2 //missing element disregarded earlier to avoid index error

-->
sum(a) //returns area of the object


The following results were obtained:

for this circle with radius of 100, the scilab program yielded an area with 3% error.

**Blogger (the site) refuses to upload both the rectangle and square pictures.

The 100x100 square (actual area 10000) when processed in the program yielded a 500 unit discrepancy, 5% error.
The actual area of the rectangle is 34000, the program gave 33120, yielding 2.6% error.

-i give myself a grade of 8 for this activity; not higher because even to me the program seems faulty, making up for missing elements at the end instead of a simple smooth program; and not lower because the resulting percentage errors were still below the acceptable 5% margin and i finished it quite quickly, it just took long to upload the report because of the problem with the internet connection.

-thank you to benj, mark, rica for their help with the program; and jeric for letting me use his pc.

Thursday, June 12, 2008

activity 1

Above is the original graph, taken from the Journal of Plant Physiology 1926. The rotation of the image was imperfectly done using paint hence the red box to at least have straight axes to base on.

These are the x-y variable values and their corresponding pixel coordinate values:

x y
x(pixels) y(pixels)
0 0
120 75
2 25
225 140
4 40
330 179
6 80
435 283
8 120
540 387
10

645

-from these it is calculated that the x-axis has 52.5 pixels per unit while the y-axis has 2.6 pixels per unit.

Below are tables for the pixel coordinates, values in pixels (coordinates minus origin coordinates), and the actual values (values in pixels divided by the calculated pixels per unit for each axis) of each X mark on the original graph.

coordinates :

values (in pixels):
x y
x y
121 140
1 65
136 135
16 60
264 134
144 59
308 138
188 63
336 209
216 134
370 283
250 208
440 365
320 290
457 368
337 293

actual values:
CO2 evolved staining time
0.019048 25
0.304762 23.07692
2.742857 22.69231
3.580952 24.23077
4.114286 51.53846
4.761905 80
6.095238 111.5385
6.419048 112.6923


From the values of the last table, the following graph was (re)constructed:

-i give myself a grade of 10 because even though the format of the y-axis values is different from the original graph; the overall appearance and upon closer inspection, the marked data points, are about precisely reconstructed.