Conversion to grayscale image from binary image
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
