Filter löschen
Filter löschen

How to change white on the outside to black?

1 Ansicht (letzte 30 Tage)
Keane Athallah
Keane Athallah am 19 Mai 2022
Kommentiert: DGM am 19 Mai 2022

Akzeptierte Antwort

DGM
DGM am 19 Mai 2022
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 Kommentare
Keane Athallah
Keane Athallah am 19 Mai 2022
i already deal with that error, Thank you so much
DGM
DGM am 19 Mai 2022
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by