필터 지우기
필터 지우기

How to change white on the outside to black?

조회 수: 1 (최근 30일)
Keane Athallah
Keane Athallah 2022년 5월 19일
댓글: DGM 2022년 5월 19일

채택된 답변

DGM
DGM 2022년 5월 19일
Some of the objects are connected to the surrounding white blob. You'll need to deal with that. You might be able to do something like:
A = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1004025/image.png');
A = rgb2gray(A)>127; % binarize
B = imopen(A,ones(3)); % try to break connectivity
B = imclearborder(B); % clear border
B = A & ~B; % difference of original and smoothed copy sans border
B = bwareafilt(B,1); % select only the border object, delete speckles
B = A & ~B; % remove border object from original image
imshow(B)
  댓글 수: 4
Keane Athallah
Keane Athallah 2022년 5월 19일
i already deal with that error, Thank you so much
DGM
DGM 2022년 5월 19일
As you've probably already figured out, your working image is probably still a single-channel logical image, whereas the attached PNG file is a uint8-scale RGB image. In that case, the conversion and thresholding isn't necessary unless dealing with a copy like the one attached.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by