convert binary image to RGB image

21 ビュー (過去 30 日間)
fereshte
fereshte 2014 年 6 月 16 日
コメント済み: Image Analyst 2015 年 9 月 28 日
how convert binary image to RGB image? my original image and binary image attached. thanks
  3 件のコメント
Joseph Cheng
Joseph Cheng 2014 年 6 月 16 日
編集済み: Joseph Cheng 2014 年 6 月 16 日
What failed? code seems fine. What are you looking for as a result?
fereshte
fereshte 2014 年 6 月 17 日
編集済み: fereshte 2014 年 6 月 17 日
same binary image but with main colors.i want to processing on colored extraction parts and dont need to binary image same heel image i want convert binary image to colored image

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

回答 (2 件)

Youssef  Khmou
Youssef Khmou 2014 年 6 月 16 日
編集済み: Youssef Khmou 2014 年 6 月 16 日
The technique you used failed because the function does not provide a visualization of three dimensional logical matrices, besides i do not think the binary to RGB transformation is possible because there are not enough information about the channels, thus RGB to binary is possible .

Image Analyst
Image Analyst 2014 年 6 月 17 日
Your code is almost okay but not quite robust enough. And you didn't scale it by multiplying by 255 so that you can see it (otherwise it will have values of just 0 or 1 which will be so dark as to be virtually invisible). If you're going to display an RGB image like that the image has to be a uint8 image in the range of 0-255. So a more robust way to do it is this (untested):
baseFileName = 'binary.bmp';
fullfileName = fullfile(pwd, baseFileName);
if ~exist(fullFileName, 'file')
message = sprintf('Image file %s was not found!', fullFileName);
uiwait(warndlg(message));
return;
end
binaryImage = imread(fullFileName);
[rows, columns, numberOfColorChannels] = size(binaryImage)
maxValue = max(binaryImage(:))
minValue = min(binaryImage(:))
if numberOfColorChannels > 1 || minValue < 0 || maxValue > 1
message = sprintf('Image is not a binary Image!');
uiwait(warndlg(message));
return;
end
grayImage = 255 * uint8(binaryImage);
RGB = cat(3, grayImage, grayImage, grayImage);
imshow(RGB);
Try that and tell me how it goes.
  9 件のコメント
Muthu Annamalai
Muthu Annamalai 2015 年 9 月 28 日
Maybe it would help if @fereshte can upload the BMP image in question to the forums ? That way you can reduce some of the back-n-forth and known limitations of MATLAB code from the answers forum
Image Analyst
Image Analyst 2015 年 9 月 28 日
The images were uploaded, back on June 17th. There's no more back and forth - I guess it's not a problem for him anymore (3 months later).

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

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by