Imfindcircles detecting massiveness?

2 visualizaciones (últimos 30 días)
Wasgeht Siedasan
Wasgeht Siedasan el 17 de Sept. de 2020
Respondida: Madhav Thakker el 22 de Sept. de 2020
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!

Respuesta aceptada

Madhav Thakker
Madhav Thakker el 22 de Sept. de 2020
Hi Wasgeht,
I understand that you want to only retain those circles which have more than 70% of pixels that are white. One of the possible ways is to go through each circle and count the number of white pixels in the circle. You can use inpolygon for checking whether a query point lies in the polygon or not. You can use polyshape to create a polygon for each circle using centre and radius.
Here is another answer which does a similar thing.
Hope this helps.

Más respuestas (0)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by