How to keep only solid white dots and eliminate dots that inside them is black in the attached image?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello, Is there any way that I could remove the dots which are black inside from the attached image to just keep the solid white dots in the image? Thanks
0 件のコメント
採用された回答
Akira Agata
2018 年 11 月 6 日
bwpropfilt function would be helpful for your task. The following is an example.
% Read the image
I = imread('Example.jpg');
% Binarize the image
BW = imbinarize(rgb2gray(I));
% Suppress light structures connected to image border
BW = imclearborder(BW);
% Filter out regions which has hole(s)
BW = bwpropfilt(BW,'EulerNumber',[1 1]);
4 件のコメント
Akira Agata
2018 年 11 月 7 日
Please use the regionprops function to detect centroid and bounding box for each area. The following is an example.
% Read the image
I = imread('Example2.jpg');
% Binarize the image
BW = imbinarize(rgb2gray(I));
% Suppress light structures connected to image border
BW = imclearborder(BW);
% Filter out regions which has hole(s)
s = regionprops(BW,{'Centroid','BoundingBox'});
% Show the result
figure
imshow(BW)
hold on
for kk = 1:numel(s)
scatter(s(kk).Centroid(1),s(kk).Centroid(2),'rx')
rectangle('Position',s(kk).BoundingBox,'EdgeColor','y')
end
Since white areas are relatively small against image size, the result becomes like this.
But if you expand part of the image, you can see the image like this:
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!