Conversion to grayscale image from binary image
3 ビュー (過去 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!
