A3: Image types and basic image enhancement TAKE 2

Since image conversion isn't allowed, here's another set of images.

Figure 1. Truecolor image of a flower taken in 2007 at the new NIP.
Figure 2. Indexed image of a root locus plot done with SciLab for Applied Physics 183.

Figure 3. Grayscale image. (http://www.mos.org/sln/SEM/diatomb.gif)

Figure 4. Binary image. (http://www.flickr.com/photos/adrianblack/2285934929/sizes/o)

For area estimation, I have scanned the following hand-drawn images with a ruler:




Figure 5. Scanned images for area estimation.

From imfinfo :


and for both images:


To determine effective threshold value for binarization, we plot histogram or the PDF as in Activity 4:
//histogram imgsize = size(Img); //get image dimensions
imgfreq = tabul(Img); //get histogram

pxvals = imgfreq(:,1); //pixel values

valfreq = imgfreq(:,2); //pixel value frequencies

allpxvals = [0:1:255];

allvalfreq = allpxvals*0;

for j = allpxvals,

allvalfreq = allvalfreq + (bool2s(allpxvals==j)*(valfreq(find(pxvals==j))));
end;

//PDF = histogram normalized with respect to total no. of pixels

numpx = imgsize(1)*imgsize(2);
PDF = allvalfreq/numpx;

fig = scf(1);

plot(allpxvals,PDF);


Figure 6 shows the PDFs for both images and we find an obvious distinction between the background and the region of interest or ROI:

Figure 6. Heart (left) and "JICA" text (right) image PDFs.

//after visual inspection and deciding on threshold
threshold = 0.5;

ROI = Img((1:imgsize(1)),(100:imgsize(2))); //select ROI

ROIBW = im2bw(ROI,threshold); //binarize based on threshold
imshow(ROIBW);


Figure 7 shows the binarized ROIs:


Figure 7. Binarized ROIs.

And as in Activity 2, we compute for the area using pixel counting and Green's area approximation:
[x,y] = follow(ROIBW); //get contour from image
len = length(x); //no. of boundary pixels

//close contour

x(len+1)=x(1);
y(len+1)=y(1);

len = length(x);
Parea = sum(ROIBW); //white pixel count (theoretical area)

Garea = sum(((x(1:1:len-1).*y(2:1:len))-(x(2:1:len).*y(1:1:len-1)))/2)+len/2; //Green's Theorem area


Area estimation results with pixel count and Green's area in pixels and the physical area in cm2:

Estimation of actual area was done using the ratios technique done in Activity 1.

I give myself a grade of 9 in this activity.

I would like to thank Mr. Paul Leonard Atchong C. Hilario and Ms. Cherry May Palomero for scanning the images for us and lending their laptops for the task and Mr. Miguel Sison for allowing us to use their group's scanner. I would also like to thank Ms. Ma. Herminia Balgos for sharing that SEM images are grayscale.

0 comments:

Post a Comment