binary to rgb image

Hello, I have a picture which is originally [0 255] in pixels but I have converted it to binary to do some image processing but now I need it to get back to original pixel to display is there a way? Regards

6 件のコメント

Michal Dobai
Michal Dobai 2017 年 12 月 20 日
'...I have converted it to binary...'
How exactly? Is your image matrix type logical or uint8? Is it already 3D matrix or just 2D? Because you shouldn't have a problem displaying binary image directly (in case of 2D). imshow() supports logical data type. If the type of your matrix class is other than logical you can always cast it to logical like this:
imshow(logical(Im));
I — Input image
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical
m
m 2017 年 12 月 20 日
編集済み: Image Analyst 2017 年 12 月 20 日
I have only do
Igray = imread('myimg')
so it is 2D image and then I convert it to binary using im2bw \
Ibw =im2bw(Igray,graythresh(Igray));
and now I want to get it back to normal colors
Michal Dobai
Michal Dobai 2017 年 12 月 20 日
You cannot convert binary image 'back to' gray-scale. You have your gray-scale image in Igray variable. Use that instead.
(or maybe I just still don't fully understand your question :)
m
m 2017 年 12 月 20 日
I have a binary image which is out from im2bw function , I have done the processing which I want on it . now I need to get this image back to it's original color after processing . hope you understand
Michal Dobai
Michal Dobai 2017 年 12 月 21 日
編集済み: Michal Dobai 2017 年 12 月 21 日
You cannot convert binary image 'back to' gray-scale. The information about pixel intensity is simply no longer there.
You can use your B&W image as mask to (for example) select all pixels above your threshold and do something with them.
% this is how you can select pixels
% from Igray that are 'white' in Ibw.
Igray(Ibw)
Now if you want to really turn binary matrix to 'RGB' image you can do:
Irgb = repmat(im2uint8(Ibw),1,1,3);
but it will still be just B&W image in 3D uint8 matrix.
Image Analyst
Image Analyst 2017 年 12 月 21 日
m, I answered about an hour before your comment. Did you actually even see the "Answers" section below???

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2017 年 12 月 20 日

0 投票

Try
Ibw = Igray;
though I don't recommend that because the variable name will be deceptive because it's now a gray level image, not a logical image anymore.

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

質問済み:

m
m
2017 年 12 月 20 日

コメント済み:

2017 年 12 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by