1
votes

I am writing a matlab code that takes in a photo and detects the circular object. After using some filters, I got below image.

enter image description here

To detect circular object(it is not a perfect circle), I tried to apply Hough Transform passing different values of radius and threshold, but it couldn't detect properly. Why this happens? Is it about shape of object or background of image?

Also is it possible to detect same object at the following image using Hough Transform?

enter image description here

Edge of circular object seems by human eye, but I am not sure that background can be eliminated from image completely via Hough Transform.

1

1 Answers

5
votes

You can use imfindcircles in the Image Processing Toolbox. Using morphology to fill in the circle and cranking up sensitivity may help:

im = imread('pattern.jpg');
im2 = rgb2gray(im(100:end-100, 100:end-100, :));
im3 = im2bw(im2, 0.1);
im4 = imclose(im3, strel('disk', 4, 4));
im5 = imfill(im4, 'holes');
imshow(im5);
[centers, radii] = imfindcircles(im5, [180, 200], 'Sensitivity', .99);
viscircles(centers, radii);

enter image description here