Conversion to grayscale image from binary image

조회 수: 2 (최근 30일)
snake eyes
snake eyes 2011년 8월 23일
답변: DGM 2025년 6월 15일
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.

답변 (1개)

DGM
DGM 2025년 6월 15일
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.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by