Monday, June 23, 2008

Activity 3: Image types and basic enhancements


This is a gray scale image converted originally from a true color image. The image properties are:
Filename-C:\Documents and Settings\Instru\Desktop\gs1n.jpg Filesize-602 Filesize-1871 kb
Format-JPEG
width-128 pixels
height-92 pixels,
depth- 8
Storage type-indexed
number of colors-256
resolution unit-inch
Xresolution-0.
Yresolution-0.
Source:blogs.mathworks.com


This is a binary image converted originally from a true color image. The image threshold I used is 0.5. The image properties are:
Filename-C:\Documents and Settings\AP186user02\Desktop\vase_bw.png Filesize-602 kb
Format-PNG
width-113 pixels
height-102 pixels
depth- 16
Storage type-true color
number of colors-0.
resolution unit-centimeter
Xresolution-0.
Yresolution-0.
Source:www.aimatshape.net


This is a true color image with the following properties:
Filename-C:\Documents and Settings\Instru\Desktop\true_color.jpg Filesize-3405 kb
Format-JPEG
width-128 pixels
height-128 pixels
depth- 8
Storage type-true color
number of colors-0.
resolution unit-centimeter
Xresolution-0.
Yresolution-0.
Source:asymptotia.com


This is a indexed image converted originally from a true color image. The image threshold I used is 0.5. The image properties are:
Filename- C:\Documents and Settings\Instru\Desktop\vase_indexed.bmp Filesize-6328 kb
Format-BMP
width-113 pixels
height-102 pixels
depth- 8
Storage type-indexed
number of colors-16.
resolution unit-centimeter
Xresolution-1.718D+09
Yresolution-1.718D+09
Source:www.aimatshape.net

The conversion from one image type to another was done using Paint. The true color image is saved to either Monochrome bitmap for binary, 16 Color bitmap for indexed and 256 Color bitmap for gray scale.

The next task is to calculate the area of a scanned image.













a b c


The original 24 Bit image (a) is converted to a 256 Color bitmap image (b) via Paint. The binary image (c) is the thresholded image of the gray scale image of the scanned image. The threshold I used is 150/max(pixel value of the image). The figure below is the histogram of the gray scale converted image of (a).

The values cluster at the white region and some in the mid-gray scale values. The separate the ROI (mostly white)from the background (mostly black), we should threshold the values to be 1 if the pixel gray level is above 150/(max pixel value of the image) and make the values 0 if it is below the threshold. On the code, the pixel values are normalized.





The area I got from the binary image converted from the gray scale image which originated from the scanned image is 135200. check this, I also calculated the dame binary image from the gray scale image thresholded by paint and I got the same result.

The Codes:
For hist: Courtesy of Jeric;
thresh=150.
im=imread('C:\Documents and Settings\Instru\Desktop\gs2.bmp');
imn=im2bw(im,thresh/max(im));
[x,y]=follow(imn);
lx=length(x);
ly=length(y);
x1(1)=x(lx);
x1(2:lx)=x(1:lx-1);
y1(1)=y(ly);
y1(2:ly)=y(1:ly-1);
area=abs(0.5*sum(x1.*y-x.*y1))

For area of the gray scale image;
thresh=150.
im=imread('C:\Documents and Settings\Instru\Desktop\gs2.bmp');
imn=im2bw(im,thresh/max(im));
[x,y]=follow(imn);
lx=length(x);
ly=length(y);
x1(1)=x(lx);
x1(2:lx)=x(1:lx-1);
y1(1)=y(ly);
y1(2:ly)=y(1:ly-1);
area=abs(0.5*sum(x1.*y-x.*y1))


For the gray scale image;
im=imread('C:\Documents and Settings\Instru\Desktop\binary_paint.bmp');
im=im-1;
[x,y]=follow(im);
lx=length(x);
ly=length(y);
x1(1)=x(lx);
x1(2:lx)=x(1:lx-1);
y1(1)=y(ly);
y1(2:ly)=y(1:ly-1);
area=abs(0.5*sum(x1.*y-x.*y1))

I will give myself points 10. because I managed to convert the images to different types. Also, I was able to validate the area via Greens Theorem using my choice of threshold and surprisingly,it is equal to the area of the same image thresholded by paint to binary.

No comments: