Convert gray to rgb
古いコメントを表示
Hey I want to change my gray image back to rgb.
This is my code
I1 = '3 new.jpeg';
img = imread(I1);
img_grey = rgb2gray(img);
A = img(:,:,3);
second_img = imsubtract(A, img_grey);
final_img = im2bw(second_img, 0.09);
imshow(final_img);
title('Final Img','fontsize',20);
rgbImage=ind2rgb(final_img,jet(256));
imshow (rgbImage);
4 件のコメント
Image Analyst
2021 年 1 月 13 日
OK, congratulations. Actually you converted a binary image (not a gray scale image) into RGB. I don't see a question anywhere, but thanks for the announcement (I guess).
Raja Ahmad Shurim Raja Zainol
2021 年 1 月 14 日
Walter Roberson
2021 年 1 月 14 日
rgbImage=ind2rgb(uint8(final_img), jet(256));
You will not be able to convert it back to the original color.
However it would be possible to use the binary image to select parts of the original image to stay the same and convert everything else to black.
finalrgb = img.*uint8(final_img) ;
Raja Ahmad Shurim Raja Zainol
2021 年 1 月 14 日
回答 (1 件)
Image Analyst
2021 年 1 月 14 日
How did you call the display function, such as imshow(), in both cases? It should work the same. Are you using GUIDE or App Designer for the "GUI" method?
To change your gray scale image back into the original RGB image, you simply assign it:
img_grey = img;
That should work as long as you still have img available.
3 件のコメント
Raja Ahmad Shurim Raja Zainol
2021 年 1 月 15 日
Walter Roberson
2021 年 1 月 15 日
We recommend against using global.
http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
subplot('Position', [0.2 0.2 0.6 0.6]);
subplot() of what axes in what figure?
Note: when you use subplot() and the position you give partly overlays an existing axes, the existing axes will be deleted.
img_grey=img;GUID
is GUID a function that you are intentionally calling there?
Note that in pushbuttoon2_Callback, you do not display anything.
Image Analyst
2021 年 1 月 15 日
Attach both the .m file and the .fig file with the paperclip icon if you need more help.
カテゴリ
ヘルプ センター および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!