Image Processing Using MATLAB: Image Deblurring and Hough Transform (Part 4 of 4)

Dr Anil Kumar Maini is former director, Laser Science and Technology Centre, a premier laser and optoelectronics R&D laboratory of DRDO of Ministry of Defence--Varsha Agrawal is a senior scientist with Laser Science and Technology Centre (LASTEC), a premier R&D lab of DRDO

12018
Advertisement

As you can see from Fig. 13, centers of circles seem to be correctly positioned and their corresponding radii seem to match well to the actual circles. However, quite a few circles were still missed. Let us increase ‘Sensitivity’ to 0.928:

>> [centers,radii]=imfindcircles(RGB,
[40 60],’ObjectPolarity’,’Dark’,
’Sensitivity’,0.98)

centers =
384.2193 204.4776
248.8446 201.4930
197.7027 73.5149
442.9998 78.3674
76.7218 76.5162
radii =
50.1646
50.2572
50.2951
49.7827
50.4039

Now, we are able to detect five circles. Hence, by increasing the value of sensitivity you can detect more circles. Let us plot these circles on the image again:

Advertisement

>>delete(h); % Delete previously drawn
circles
>>h = viscircles(centers,radii);

Replotted circles
Fig. 14: Replotted circles

Fig. 14 shows the result.

8. As you can see, function imfindcircles does not find yellow and white circles in the image. Yellow and white circles are lighter than the background. In fact, these seem to have very similar intensities as the background. To confirm this, let us see the grayscale version of the original image again. Fig. 15 shows the grayscale image.

>>figure, imshow(gray_image)

Grayscale version of the image in Fig. 14
Fig. 14: Grayscale version of the image in Fig. 14

9. To detect objects brighter than the background, change ‘ObjectPolarity’ to ‘bright’:

>> [centers,radii]=imfindcircles(RGB,
[40 60],’ObjectPolarity’,’Bright’,
’Sensitivity’,0.98)
centers =
323.2806 75.9644
122.3421 205.1504
radii =
49.7654
50.1574

10. Draw bright circles in a different colour by changing ‘Colour’ parameter in viscircles:

>>imshow(RGB)
>>hBright=viscircles(centers,radii,
’Color’,’b’);

Bright circles drawn in a different colour
Fig. 16: Bright circles drawn in a different colour

Fig. 16 shows the image.

11. There is another parameter in function imfindcircles, namely, EdgeThreshold, which controls how high the gradient value at a pixel has to be before it is considered an edge pixel and included in computation. A high value (closer to 1) for this parameter will allow only the strong edges (higher gradient values) to be included, whereas a low value (closer to 0) is more permissive and includes even the weaker edges (lower gradient values) in computation. Therefore, lower the value of EdgeThreshold parameter, more are the chances of a circle’s detection. However, it also increases the likelihood of detecting false circles. Hence, there is a trade-off between the number of true circles that can be found (detection rate) and the number of false circles that are found with them (false alarm rate).
Following commands detect both the bright and the dark objects and encircle them:

>>[centersBright,radiiBright,metricBright]
=imfindcircles(RGB,[4060], ‘ObjectPolarity’,
’bright’,’Sensitivity’,0.9,’EdgeThreshold’,
0.2);
>>imshow(RGB);
>> h=viscircles(centers,radii);
>>hBright=viscircles(centersBright,
radiiBright,’Color’,’b’);

Both the bright and the dark objects detected and encircled
Fig. 17: Both the bright and the dark objects detected and encircled

Fig. 17 shows the output image.


For reading other MATLAB projects: click here

 

Advertisement


SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here