how to set the background color of this image to 0 and remaining foreground color to 1 to make this image binary?

1 vue (au cours des 30 derniers jours)
Colored Watershed Label Matrix.png

Réponse acceptée

Image Analyst
Image Analyst le 30 Mar 2019
Make a mask:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Now make the mask
mask = ~(recChannel ~= 0 & greenChannel == 0 & blueChannel == 0);
  2 commentaires
Arshad Ali
Arshad Ali le 30 Mar 2019
if the image is like this, then the code will be the same.
Colored Watershed Label Matrix.png
Image Analyst
Image Analyst le 30 Mar 2019
Your colors are not pure.
When I tried to save the image it looks like this is a labeled image returned from the watershed function, so you should already have the binary image to begin with, so that is what you want. You can also get it from the labeled matrix like
binaryImage = labeledMatrix ~= 0;
but that should not be necessary. Not sure how the white boundary lines got there though.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Modify Image Colors dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by