Finding solid circles using imfind circles

3 ビュー (過去 30 日間)
divya r
divya r 2014 年 5 月 5 日
コメント済み: Image Analyst 2014 年 5 月 6 日
Is there any way to make sure the circles detected by the imfindcircles function is a solid circle and has no black pixels inside of it?

採用された回答

Image Analyst
Image Analyst 2014 年 5 月 5 日
Make a mask from the circle, then
hasBlackInside = min(grayImage(mask)) == 0;
hasBlackInside will be true if there is at least one black pixel inside the mask.
  2 件のコメント
divya r
divya r 2014 年 5 月 6 日
I have 2 doubts about this. 1. According to my understanding, by using min on the masked image, it will find is a black pixel is present in every column of the image matrix and not only inside the mask.
2. If I have multiple circles in an image, and want to remove only those which have some black pixels in them, how can I do it?
Image Analyst
Image Analyst 2014 年 5 月 6 日
1. Not true.
2. You can take the mask with all the circles identified, then label it and run it through regionprops() asking for PixelList and PixelIdxList, which is a list of all pixel values in each blob. Have a loop over all regions. Check the min of PixelList for each blob. If the min is zero (or less than some value), then use PixelIdxList to set all those pixels in the binary image to zero (false). Then relabel and call regionprops again to get measurements on just the remaining blobs. Untested code:
[labeledImage, numberOfRegions] = bwlabel(mask);
measurements = regionprops(labeledImage, 'PixelIdxList', 'PixelList');
for k = 1 : numberOfRegions
thisBlobsPixels = grayImage(measurements(k).PixelIdxList);
minGL = min(thisBlobsPixels);
if minGL == 0
binaryImage(thisBlobsPixels) = false; % Erase this blob.
end
end
% binaryImage will not have no circles that had a zero in the gray image.
% Remeasure remaining blobs.
[labeledImage, numberOfRegions] = bwlabel(mask);
% Measure something if you need to.
measurements = regionprops(labeledImage, 'all');

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by