필터 지우기
필터 지우기

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

채택된 답변

Akira Agata
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
Penny13
Penny13 2018년 11월 6일
Thanks a lot for your answer. If you don't mind I will ask one last question. For every dot that I have in this image Example2.jpg, How could I draw a square with only having the centroid of the dot?
Akira Agata
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개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by