In image-based measurements, it is often desired that the region of interest (ROI) is made well segmented from the background either by edge detection or by specifying the ROI as a blob.
Binarizing an image simplifies the separation of background from ROI. However, the optimum threshold must be found by examing the histogram.
Procedure:
1. Cut the image in 256 x 256 subimages.
In my case, I have 12 subimages.
2. Find the threshold of the image.
3. Binarize the image
bw = im2bw(im, 0.84);
subplot(142)
imshow(bw, [])
xtitle('binary')
4. Closing operator - dilate then erode
//closing operator
SE = ones (4,4);
imdilatec = dilate(bw, SE);
imerodec = erode(imdilatec, SE);
subplot(143)
imshow(imerodec, [])
xtitle('closing')
Opening operator - erode then dilate
//opening operator
SE = ones (4, 4);
imerodeo = erode(bw, SE);
imdilateo = dilate(imerodeo, SE);
subplot(144)
imshow(imdilateo, [])
xtitle('opening')
* we will not use both operators, we will just choose which one will show a good image where the blobs are defined.
5.Use bwlabel to label each contiguous blob on the binarized image.
// Label every connected component with a unique number.
[L, n] = bwlabel(imdilateo);
// Shows each component with a different color
scf(1)
subplot(121)
imshow(imdilateo, [])
subplot(122)
imshow(L+1,rand(n+1,3));
xtitle('label')
6. Find the area
for i=1:n
[r,c] = find(L==i);
a=size(r);
area(i) = a(2)
end
One of the subimages is shown below:
subimage1
After finding the area by pixel counting, it will show this histogram(using Excel)
From the graph, it shows that the area of the blob is near 525-500. I only use the areas of the circle from 400 to 700 because I think that below 400, the circle is truncated and more than 700 there is overlapping of circles.
Verifying our assumption:
1. I find the diameter of the blob, using GIMP, the diameter is around 26 pixels. Hence, the radius is 13 pixels. Using the formula for circle, which is pi*(r^2), the area should be 531 pixels which is in the range.
2. Another method is to pixel count a blob, it is found that the area is around 537 pixels, which is still in the range.
3. We will get the mean and the standard deviation.
Mean: 527 pixels
Standard Deviation: 22 pixels
which is still in the range of the peak from the histogram.
Acknowledgements:
Lei
Beth
Aiyin
Ed
- for the help. :)
Grade:
10/10
because I did what is needed to do.
Thursday, July 17, 2008
A9 – Binary Operations
Posted by anarica at 9:10 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment