For true color the image the image format used is jpeg, as originally obtained from my source [1]. For binary the same image was saved as monochrome bitmap but threshold was performed using gimped. For the indexed image, the same image was saved as gif. Lastly for the Grayscale, gif format was also used.
The following attributes was found using imfinfo of scilab:
Truecolor
FileName: C:\Documents and Settings\semicon\Desktop\activity3\final\leaf_truecolor.jpg
FileSize: 17462
Format: JPEG
Width: 256
Height: 192
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: inch
XResolution: 96.000000
YResolution: 96.000000
Binary
FileName: C:\Documents and Settings\semicon\Desktop\activity3\final\leaf_binary.bmp
FileSize: 6206
Format: BMP
Width: 256
Height: 192
Depth: 8
StorageType: indexed
NumberOfColors: 2
ResolutionUnit: centimeter
XResolution: 37.800000
YResolution: 37.800000
Indexed
FileName: C:\Documents and Settings\semicon\Desktop\activity3\final\leaf_indexed.gif
FileSize: 42446
Format: GIF
Width: 256
Height: 192
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 72.000000
YResolution: 72.000000
Grayscale
FileName: C:\Documents and Settings\semicon\Desktop\activity3\final\leaf_gray.gif
FileSize: 53263
Format: GIF
Width: 256
Height: 192
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 72.000000
YResolution: 72.000000
For the second part of the activity we are to measure the area of a flat image. The image I used is an ATM card shown below. Also shown is the histogram of the said image obtained using GIMP.
The following information on the image was obtained using imfinfo function of scilab:
FileSize: 95057
Format: PNG
Width: 504
Height: 323
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 118.110000
YResolution: 118.110000
It can be seen from the histogram that the region of interest (lower pixel values) is well separated from the background (higher pixel values).
Thresholding was done using the im2bw command of scilab using 0.6 as the threshold value. After thresholding, the following image and histogram was obtained:
As seen from the histogram, Only 2 pixel values is present, o and 255. This proves that the image is now binary. However using the imfinfo function of scilab, I obtained the following information:
FileName: C:\Documents and Settings\semicon\Desktop\ATM\atmBW.bmp
FileSize: 163870
Format: BMP
Width: 504
Height: 323
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 28.340000
YResolution: 28.340000
Obviously, scilab imfinfo believes that the image is not yet binary. But I tried to save it in a different image format (gif) the number of colors changed to 2:
FileName: C:\Documents and Settings\semicon\Desktop\ATM\atmBW.gif
FileSize: 4505
Format: GIF
Width: 504
Height: 323
Depth: 8
StorageType: indexed
NumberOfColors: 2
ResolutionUnit: centimeter
XResolution: 72.000000
YResolution: 72.000000
Apparently, Scilab prefers to save images in gif format for binary images.
I integrated the area calculation routine from the previous activity with the image conversions of this activity. I obtained an area of 160759, the theoretical area is 162792 giving me a percentage error of 1.25%
For this activity I will give myself a score of 10 because I was able to obtain a good image threshold and for the area calculation I was able to get a very small error of 1.25%
The Scilab code I used for this activity is given below:
-------------------------------------------------------
I = imread('C:\Documents and Settings\semicon\Desktop\ATM\atm.bmp');
//I = im2gray(I);
I = im2bw(I,0.6);
I = abs(I-1);
imwrite(I,'C:\Documents and Settings\semicon\Desktop\ATM\atmBW.bmp');
[x,y] = follow(I,8);
sizex = size(x); //obtain matrix size
sizey = size(y);
x1 = x; //define new variables x1 and y1
y1 = y;
x1(2:sizex(1)) = x(1:sizex(1)-1); //shift x1
x1(1) = x(sizex(1));
y1(2:sizey(1)) = y(1:sizey(1)-1); //shift y1
y1(1) = y(sizey(1));
dif = x.*y1-y.*x1; //green's theorem
A = abs(0.5*sum(dif))
------------------------------------------------------
Eduardo David and Elizabeth Ann Prieto helped me with this activity.
the image source (leaf) is:
http://www.pdphoto.org/jons/pictures2/leaf_1_bg_010503.jpg
No comments:
Post a Comment