I am using hyperspectral datasets from this website: http://www.spectir.com/free-data-samples/. I can visualise a picture in gray but not in colour. How can I convert the gray image to an RGB colour image?
Thanks in advance

1 件のコメント

Yogesh Awate
Yogesh Awate 2017 年 11 月 15 日
Can someone send me the whole program?

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

回答 (2 件)

Image Analyst
Image Analyst 2012 年 10 月 11 日

0 投票

Put each spectral channel into one of the color channels:
rgbImage = cat(3, spectralChannel1, , spectralChannel3, , spectralChannel8);
imshow(rgbImage);
or whatever channels you want to use.

12 件のコメント

Alexandros Polykarpou
Alexandros Polykarpou 2012 年 10 月 11 日
編集済み: Alexandros Polykarpou 2012 年 10 月 11 日
I am new to matlab. I am not sure what am I supposed to do. Can you give a bit more detail?
So I have two matrices. One representing reflectance and the other one radiance. How can i apply the above formula.
Thanks
Image Analyst
Image Analyst 2012 年 10 月 11 日
rgbImage = cat(3, reflectance, radiance, zeros(size(radiance)));
imshow(rgbImage);
Alexandros Polykarpou
Alexandros Polykarpou 2012 年 10 月 11 日
I got this error any ideas?
Error using imageDisplayValidateParams>validateCData (line 117) Unsupported dimension.
Error in imageDisplayValidateParams (line 31) common_args.CData = validateCData(common_args.CData,image_type);
Error in imageDisplayParseInputs (line 79) common_args = imageDisplayValidateParams(common_args);
Error in imshow (line 198) [common_args,specific_args] = ...
Image Analyst
Image Analyst 2012 年 10 月 11 日
Are the images monochrome or color? I'm assuming they're monochrome. What does this say:
size(reflectance)
size(radiance)
Alexandros Polykarpou
Alexandros Polykarpou 2012 年 10 月 11 日
ans =
600 320 356
Both of them
Image Analyst
Image Analyst 2012 年 10 月 11 日
編集済み: Image Analyst 2012 年 10 月 11 日
Tell me why your spectral image is already in color. Each spectral band should be one monochrome image. Is the image gray? Are the red, green, and blue channels all identical? Can you call grab just one channel:
grayImage = reflectance(:, :, 2); % Get green channel.
Alexandros Polykarpou
Alexandros Polykarpou 2012 年 10 月 12 日
slice=reflectances(:,:,15); figure; imagesc(slice); colormap('gray');
This is how i plot the picture in grey. When I remove the colormap and i plot a slice of the image I get a blueish color mixed with other colors. Is this how it is supposed to be?
Image Analyst
Image Analyst 2012 年 10 月 12 日
No. A gray colormap should make the image look grayscale, not blue + other colors.
Alexandros Polykarpou
Alexandros Polykarpou 2012 年 10 月 12 日
this is what i am saying. When i remove that I get the picture with blue + other colours. Any ideas how to plot the picture in colour?
Image Analyst
Image Analyst 2012 年 10 月 12 日
When you do this:
slice=reflectances(:,:,15);
it takes the 15th color plane of reflectances. This is a 2D image - it is not color. When you use imagesc(slice), it (for some reasons that I've never figured out) applies some kind of bizarre colormap. However when you apply the gray colormap, it should fix it and show up in gray. I think you called colormap() incorrectly. You should use colormap(gray(256)) - no single quotes. Even better, use imshow() instead of imagesc().
Alexandros Polykarpou
Alexandros Polykarpou 2012 年 10 月 12 日
I know what that is. the question is how can i plot the whole picture with colour. not just a slice.
worku jifara
worku jifara 2017 年 2 月 9 日
i think this may be helpful for you load('ref_crown3bb_reg1.mat') x=reflectances(:,:,17); figure; imagesc(x); colormap('gray');brighten(0.5); y = reflectances(:,:,25); figure; imagesc(y); colormap('gray');brighten(0.5); z=reflectances(:,:,33); figure; imagesc(z); colormap('gray');brighten(0.5); all=cat(3,x,y,z); figure; imshow(all)

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

Image Analyst
Image Analyst 2017 年 11 月 15 日

0 投票

See this paper that describes a variety of ways to convert spectral bands to RGB: http://my.ece.msstate.edu/faculty/du/JSTARS-VIS.pdf

カテゴリ

ヘルプ センター および File Exchange で Color and Styling についてさらに検索

質問済み:

2012 年 10 月 11 日

回答済み:

2017 年 11 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by