Activity 10- Binary Operations

After knowing the dilation and erosion functions, it would be best to apply it to a more realistic but fun way of image processing. From UVLe, images of circles from punch paper was obtained. It is shown below.

Circles from punched papers

The aim here was to evaluate the best estimate of the area of the circular papers. So for an easier work for scilab, the large image was cropped into smaller 256×256 images and they were overlapping so that it would somehow fit an indivisible 658×823 image. It was partitioned into 12 subimages. Then, it was coverted to a binary image by first getting the histogram information and thresholding so that the circles will be easily distinguished from the background. The threshold value used was 0.8 from its grayscale image. Dilation and erosion functions would be possible in order to further clean out the binary image. Shown below is a sample of a subimage and cleaned binarized subimage (since it would be impractical to show all the subimages).

A potion of the larger image above(not yet binarized)

Cleaned binary subimage by opening

Morphological opening is removes the black pixels in the circles and the smaller pixels clusters outside the circles. This is done by first eroding the image with a circle of smaller size than the circles but larger than the cluster of pixels. Code is shown below:

x = linspace(-1,1,40);
[X,Y] = meshgrid(x);
r = sqrt(X.^2 + Y.^2);
circle = zeros(size(X,1), size(X,2));
circle(find (r <=0.5)) = 1.0;
new_Img_binary = dilate(erode(Img_binary,circle),circle); //Img_binary is the binary conversion of the subimage

Now after doing the code for 12 subimages, we go to calculating the area of the circles while disregarding those circles which obviously overlapped in order to maintain a more precise measurements. This is done by labeling each continuous blob with increasing integers starting from 1. This is done by using bwlabel. Then we take the frequency of each number and this corresponds to the area in pixels of each circle. Now by observing how many overlapping circles are present in the subimage, we remove it from the list by removing the blobs whose area is larger than the rest. Every area calculated is stored in excel and after doing all the 12 subimages, I get the best estimate to be 491.925925925926 +/- 61.4057096669212. We take note here that some of circles’ area repeats since the cropped subimages overlaps and also some of the computed area is lesser than the expected from the fact that boundaries of subimages presents a cut circle as shown below.

Circle on right boundary is somewhat cut so lesser area is computed from it

Now, we go to separating/segregating circles of different sizes like in the image below:

The above image is a collection of punched papers of different sizes. It is already binarized. We want to separate the larger circles from the smaller ones. I used morphological opening by selecting a circular structure which is larger than smaller circle but must be smaller than the larger ones so that after erosion, only the smaller ones will vanish. The final image presented below:

Smaller circles removes from the above image

I would give myself a grade of 10 for this activity since I was able to properly execute what was being told and I was able to apply the knowledge I learned from the previous activity. Although systematic error was made from the cropping of the larger as discussed earlier.

About jrafrica

applied physics student
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment