How do I perform sobel filtering in multiple detected circles (using imfindcircles, viscircles) exclusively ?

3 views (last 30 days)
I am trying to apply filter to multiple circular regions of the image. Since the edges of the circle are discontinued at some parts, how do i achieve exclusive filtering in the circular region? Used imfindcircles and viscircles to detect the circles.
Here, A_bw is the image
[centers,radii] = imfindcircles(A_bw,[30 8000]); %A_bw is the image
centersStrong5 = centers(1:7);
radiiStrong5 = radii(1:3);
viscircles(centers, radii,'EdgeColor','r','LineStyle','-.');
PS am new at it.
Thanks a lot for helping! :)

Accepted Answer

Shanmukha Voggu
Shanmukha Voggu on 5 Aug 2021
I understood that some of the circles have discontinued edges when using “imfindcircles” function so that you cannot exclusively filter the circular regions.
You have to select both x and y coordinates of centers. In order to do that,
centersStrong5 = centers(1:7);
centersStrong5 = centers(1:7,:);
The no of rows in centersStrong5 and radiiStrong5 must be same. In order to do that,
radiiStrong5 = radii(1:3);
[rowsInCentersMatrix , ~] = size(centersStrong5)
radiiStrong5 = radii(1:rowsInCentersMatrix); % Here rowsInCentersMatrix in 7
There are 3 types of circles
1)overlapped circles inside the figure(refer this if you do not want overlapping)
2)circles without overlapping inside the figure
3)circles that are cut at the ends of image(may be overlapped or not)
You can make LineStyle: ‘-‘ in order to have continuous edge without dashed edge
In order to have only circle regions(1,2 types of circles) without discontinued edges. The following code can be used to remove the discontinued edges of the circles from the group of circles in the figure.
J = imread('image.png'); %image.png is the sample image
[centers, radii] = imfindcircles(J,[30 8000]); %J is the image
[height , width]=size(J);
centersStrong = centers(filteredIndexes,:);
radiiStrong = radii(filteredIndexes);
viscircles(centersStrong, radiiStrong,'EdgeColor','r','LineStyle','-');
I recommend using sobel filter as mentioned here instead of using “imfindcircles” and “viscircles” functions

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!