Conversion to grayscale image from binary image
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I've converted a grayscale image to binary image using "im2bw" function. Now I want to do the opposite, i,e; i want to convert the binary image to grayscale image. How can I do it?
Thanks in advance.
0 commentaires
Réponses (1)
DGM
le 15 Juin 2025
If your binary image is a logical image, as returned from im2bw() or imbinarize(), then it can be converted to a numeric class using im2double(), im2uint8() or other similar functions.
inpict = imread('cameraman.tif'); % uint8 grayscale image
mask = imbinarize(inpict); % a logical image
outpict = im2uint8(mask); % the same binarized image in uint8
montage({inpict,mask,outpict},'size',[1 3],'bordersize',10,'backgroundcolor','m')
All that does is rescale the data and change its class. The result is still a binary image, even though it's no longer a logical image. This option does not recover the original image. Once an image is binarized, all that information is gone. If you want the original image, use the original image.
0 commentaires
Voir également
Catégories
En savoir plus sur Convert Image Type 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!
