how can i get grayscale color in my binary image?

3 vues (au cours des 30 derniers jours)
Farah Nadiah
Farah Nadiah le 14 Mai 2016
Commenté : Image Analyst le 13 Nov 2024
i want the intensity color in my binary image because after i get that i want to use threshold adaptive method. because in threshold i want to differentiate the dark intensity and bright. within by use threshold i can get only the image i want...thank you.
  3 commentaires
Farah Nadiah
Farah Nadiah le 14 Mai 2016
this is my grayscale image
this is my binary image
i want in binary that have their grayscale intensity because i want to detect the small dot and to do threshold at the result image..thank you
Image Analyst
Image Analyst le 13 Nov 2024
@Farah Nadiah you can just multiply your binary image by your gray scale image
grayImage2 = grayImage .* uint8(binaryImage);
or you can use indexing to set the black parts to black while keeping the gray parts
grayImage2 = grayImage; % Initialize
grayImage2(~binaryImage) = 0; % Black in binary will be set to black in the gray scale image.

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 14 Mai 2016
If you have a binary image, BW, then the intensity image that corresponds is
IntensityImage = double(BW);
  1 commentaire
Walter Roberson
Walter Roberson le 14 Mai 2016
A binary image by definition is exactly two intensities. A binary image cannot have grayscale intensity.
What you probably want is to use .* to multiply your binary image by your grayscale image. The result will be a grayscale image that is 0 everywhere the binary image was 0.

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 14 Mai 2016
You can mask your image to show only the pixels in the binary blob locations but with their original grayscale intensity like this:
outputImage = grayImage; % Initialize
% Now make black in binary image black in the gray scale image.
outputImage(~binaryImage) = 0; % Be sure to use the ~ tilde!
imshow(outputImage, []); % Or don't use [] if you don't want it to scale intensity.

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by