Imfindcircles detecting massiveness?
Show older comments
Hello,
I was using the code output from the image segmenter App in matlab to build a function that recognizes circles, cuts them out and accumualtes them on a new picture.
Input:

Code:
BW1 = imread ('test.png');
figure;
subplot(1,2,1),
imshow(BW1);
title('original')
Rmin = 22;
Rmax = 65;
% Find circles
[centersBright, radiiBright] = imfindcircles(BW1,[Rmin Rmax],'ObjectPolarity','bright','Sensitivity',0.90, 'EdgeThreshold',0.1);
viscircles(centersBright, radiiBright,'Color','b');
BW = false(size(BW1,1),size(BW1,2));
[Xgrid,Ygrid] = meshgrid(1:size(BW,2),1:size(BW,1));
[m,n] = size(centersBright);
for x = 1:m
BW = BW | (hypot(Xgrid-centersBright(x,1),Ygrid-centersBright(x,2)) <= radiiBright(x));
end
%change picture format to create masked image
uint8Image = uint8(255 * BW1);
thresh = multithresh(uint8Image,3);
seg_I = imquantize(uint8Image,thresh);
RGB = label2rgb(seg_I);
% % % Create masked image.
maskedImage = RGB;
maskedImage(repmat(~BW,[1 1 3])) = 0;
subplot(1,2,2),
imshow(maskedImage);
title('masked')
Output

Now, I want to increase sensitivity to find more circles, but it starts pickung up a lot of junk aswell.
I would like to include an IF statement in the for-loop that only lets circles pass that are at least 70% filled out or so, so not too much junk gets through. How could I do that? I don't think imfindcicrles has an output that would help here. I'd need the number of white vs black pixels in the circle somehow, aka the massiveness of the detected circle.
Also, the image segmenter app does not take binary, only RGB or grayscale, so I had to also cheat a little bit with the image conversions in the middle of the code there so the repmat would do it's job, is there some way to adjust the repmat to make tha tunnecessary?
Thanks in advance for the help!
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!