Binary Image
(http://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/test/resources/images/fop-logo-mono-1bit.png)
FileName : fop-logo-mono-1bit.gif
FileSize :14185
Format: GIF
Width: 771
Height: 392
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 0
YResolution: 0
Grayscale Image
(http://graphics.stanford.edu/data/voldata/)
FileName: mrbrain-8bit060.GIF
FileSize: 42107
Format: GIF
Width: 256
Height: 256
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Truecolor Image
(http://www.flickr.com/photos/sarabetset/2788219273/in/datetaken/)
FileName: Lotus.jpg
FileSize: 32291
Format: JPEG
Width: 398
Height: 400
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Indexed Image
(http://wpcontent.answers.com/wikipedia/commons/f/ff/8_bit.png)
FileName: 8_bit.png
FileSize: 38455
Format: PNG
Width: 300
Height: 225
Depth: 8
StorageType: indexed
NumberOfColors: 255
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
FileName : fop-logo-mono-1bit.gif
FileSize :14185
Format: GIF
Width: 771
Height: 392
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
XResolution: 0
YResolution: 0
Grayscale Image
(http://graphics.stanford.edu/data/voldata/)
FileName: mrbrain-8bit060.GIF
FileSize: 42107
Format: GIF
Width: 256
Height: 256
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Truecolor Image
(http://www.flickr.com/photos/sarabetset/2788219273/in/datetaken/)
FileName: Lotus.jpg
FileSize: 32291
Format: JPEG
Width: 398
Height: 400
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Indexed Image
(http://wpcontent.answers.com/wikipedia/commons/f/ff/8_bit.png)
FileName: 8_bit.png
FileSize: 38455
Format: PNG
Width: 300
Height: 225
Depth: 8
StorageType: indexed
NumberOfColors: 255
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
These ones are similar images converted into the different image types using GIMP (2.4.6). The original image was taken from http://www.flickr.com/photos/sarabetset/2788239981/.
Binary Image
FileName: My Umbrella-binary.GIF
FileSize: 3194
Format: GIF
Width: 500
Height: 425
Depth: 8
StorageType: indexed
NumberOfColors: 2
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
FileName: My Umbrella-binary.GIF
FileSize: 3194
Format: GIF
Width: 500
Height: 425
Depth: 8
StorageType: indexed
NumberOfColors: 2
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Grayscale Image
FileName: My Umbrella-grayscale.GIF
FileSize: 95985
Format: GIF
Width: 500
Height: 425
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Truecolor Image
FileName: My Umbrella.jpg
FileSize: 15084
Format: JPEG
Width: 400
Height: 340
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Indexed Image
FileName: My Umbrella-indexed.GIF
FileSize: 64127
Format: GIF
Width: 500
Height: 425
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
FileName: My Umbrella-grayscale.GIF
FileSize: 95985
Format: GIF
Width: 500
Height: 425
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Truecolor Image
FileName: My Umbrella.jpg
FileSize: 15084
Format: JPEG
Width: 400
Height: 340
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
Indexed Image
FileName: My Umbrella-indexed.GIF
FileSize: 64127
Format: GIF
Width: 500
Height: 425
Depth: 8
StorageType: indexed
NumberOfColors: 256
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
For the other part of this activity, thresholding was done to obtain the region of interest from an image for which area estimation (from the previous activity) would be applied.
FileName: finger.JPG
FileSize: 70206
Format: JPEG
Width: 640
Height: 480
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
FileSize: 70206
Format: JPEG
Width: 640
Height: 480
Depth: 8
StorageType: truecolor
NumberOfColors: 0
ResolutionUnit: centimeter
Xresolution: 0
Yresolution: 0
First, the original image was converted into grayscale:
image = imread('finger.JPG');
grayimage = im2gray(image);
grayimage = im2gray(image);
From here, only grayscale values are contained in the single image array. These grayscale values can easily be counted to obtain the histogram of the grayscale image.
Notice from the figure that the x-axis was from a scale of 0 to 1. This would help identify the threshold or level at which to isolate the region of interest (the fingers) from the background and set this as white, and the background black. It can easily be seen that the threshold value can be around 0.6 because most of the image is from the background with low grayscale values and the signal from the fingers occurs above this range.
Code from Scilab for computing and displaying the histogram:
grayimage = 255*grayimage;
graylevels = min(grayimage):max(grayimage);
histogram = zeros(length(graylevels));
for i = min(grayimage):max(grayimage);
histogram((i-min(graylevels))+1)=sum(1*(uint8(grayimage)==uint8(i)));
end;
scf(1);
plot(graylevels/255, histogram);
xlabel('Normalized Grayscale');
ylabel('Frequency');
title('Histogram of Scanned Image in Grayscale');
grayimage = 255*grayimage;
graylevels = min(grayimage):max(grayimage);
histogram = zeros(length(graylevels));
for i = min(grayimage):max(grayimage);
histogram((i-min(graylevels))+1)=sum(1*(uint8(grayimage)==uint8(i)));
end;
scf(1);
plot(graylevels/255, histogram);
xlabel('Normalized Grayscale');
ylabel('Frequency');
title('Histogram of Scanned Image in Grayscale');
Notice from the figure that the x-axis was from a scale of 0 to 1. This would help identify the threshold or level at which to isolate the region of interest (the fingers) from the background and set this as white, and the background black. It can easily be seen that the threshold value can be around 0.6 because most of the image is from the background with low grayscale values and the signal from the fingers occurs above this range.
bwimage = im2bw(grayimage/255, 0.6);
imwrite(bwimage, 'bwfinger.jpg');
imwrite(bwimage, 'bwfinger.jpg');
As seen in the image above, a black and white image is obtained, with the white signal coming from the region of interest: the fingers. The area estimation technique from the previous activity can now be applied for this image.
Area estimation:
[x, y] = follow(bwimage); //Obtain coordinates of the contour
m = size(x)+1;
n = size(y)+1;
x(m(1)) = x(1);
y(n(1)) = y(1);
a = x(1:m(1)-1).*y(2:n(1))-y(1:n(1)-1).*x(2:m(1));
Area = round(0.5*(sum(a)+m(1)))
//Formula from Green's theorem
If the coordinates of the contour is plotted, the result is:
The outline correspond well with the shape of the fingers in the image. The area taken up by the fingers from the area estimation algorithm above is 54732 (pixels). As a comparison, since the black and white image array have values of 1 for the region of the fingers (otherwise, 0), the sum of the array would also be equal to the area taken up by the fingers. The result is equal to the previous, which is 54732.
This gives a very accurate result and a powerful tool that can be used for measuring (or giving an estimate of) an area. It has very important applications that can be used in various fields (as stated in the previous activity).
For this activity, I think I can get a high grade (hopefully, 10) for doing a good job and also for creating my own code for computing and plotting the histogram.
I would like to acknowledge Winsome Chloe Rara, Miguel Sison, and Dr. Maricor Soriano for the assistance they have given me in doing this activity.
Area estimation:
[x, y] = follow(bwimage); //Obtain coordinates of the contour
m = size(x)+1;
n = size(y)+1;
x(m(1)) = x(1);
y(n(1)) = y(1);
a = x(1:m(1)-1).*y(2:n(1))-y(1:n(1)-1).*x(2:m(1));
Area = round(0.5*(sum(a)+m(1)))
//Formula from Green's theorem
If the coordinates of the contour is plotted, the result is:
The outline correspond well with the shape of the fingers in the image. The area taken up by the fingers from the area estimation algorithm above is 54732 (pixels). As a comparison, since the black and white image array have values of 1 for the region of the fingers (otherwise, 0), the sum of the array would also be equal to the area taken up by the fingers. The result is equal to the previous, which is 54732.
This gives a very accurate result and a powerful tool that can be used for measuring (or giving an estimate of) an area. It has very important applications that can be used in various fields (as stated in the previous activity).
For this activity, I think I can get a high grade (hopefully, 10) for doing a good job and also for creating my own code for computing and plotting the histogram.
I would like to acknowledge Winsome Chloe Rara, Miguel Sison, and Dr. Maricor Soriano for the assistance they have given me in doing this activity.
No comments:
Post a Comment