MATLAB Answers

How to create RGB image with 3 bands from hyperspectral image?

43 ビュー (過去 30 日間)
Duygu Ocal
Duygu Ocal 2015 年 3 月 16 日
編集済み: Subhadeep Koley 2021 年 3 月 31 日
Hi, I have a Hyperion EO-1 satellite image and i want to create an RGB band with band numbers (40,31,13) as (R,G,B). The hyperion image has 242 bands. But I'm having trouble opening the L1R file properly.
I am using Matlab 2011, and 2014 hyperion image. I load the image with hdfinfo and hdfread commands like this;
hdfinfo('EO1H1930282003203110PY.L1R');
fileinfo = hdfinfo('EO1H1930282003203110PY.L1R');
sds_info = fileinfo.SDS(1);
hdfread(sds_info);
ans=imhdf;
But this loads a matrix [3128,242,256] , although it should be [3128,256,242] how can i fix this?
After loading the image as 3D matrix i try to create the RGB image with selecte 3 bands as shown below it creates [3128,3,256] matrix but I cant use imwrite, imshow or any other displaying functions on it.
imrgb [:,1,:] = imhdf [:,40,:];
imrgb [:,2,:] = imhdf [:,31,:];
imrgb [:,3,:] = imhdf [:,13,:];
image(imrgb);
Error using image
Error using image
Indexed CData must be size [MxN], TrueColor CData must be
size [MxNx3]
Please answer, thank you.
  1 件のコメント
kirti khemka
kirti khemka 2015 年 8 月 7 日
i m using the same code for my image error occured ??? Error using ==> permute Out of memory. Type HELP MEMORY for your options.
Error in ==> hdfsdsread at 53 data = permute(data,ndims(data):-1:1);
Error in ==> hdfread at 234 varargout{1} = hdfsdsread(hinfo,start,stride,edge);

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

採用された回答

Cong Huynh
Cong Huynh 2015 年 8 月 14 日
You could use the Scyllarus hyperspectral image processing toolbox. The MATLAB version of this toolbox is available for non-commercial use and can be downloaded from http://scyllarus.research.nicta.com.au/
To load and save multispectral images (consisting of pairs of .hdr and .fla files), the functions to look at are FLARead and FLAWrite under src/io. With these functions you can read from and write to the .fla format (ENVI-compatible), rather than any colour image format. Alternatively you can save the image to a .mat file but this option usually produces a much larger image.
To convert a hyperspectral image to RGB, you could use the function recover_RGBImage.m under /src/shared. There are examples in that .m file.
  1 件のコメント
Adnan Farooq Awan
Adnan Farooq Awan 2017 年 11 月 7 日
I have an hyperspectral data taken from Brimrose VA210 sensor. I have 61 bands. Can I use this toolbox for that?

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

その他の回答 (3 件)

Ben Worker
Ben Worker 2015 年 7 月 15 日
Here is a sample code to try. It allowed me to view LR1 images.
field_info=hdfinfo(FILE_NAME);
sds_info = field_info.SDS(1);
imhdf=hdfread(sds_info);
imrgb(:,:,1) = imhdf(:,27,:);
imrgb(:,:,2) = imhdf(:,18,:);
imrgb(:,:,3) = imhdf(:,9,:);
imrgb = double(imrgb);
gain = 3000;
imshow(imrgb/gain)
  1 件のコメント
Adnan Farooq Awan
Adnan Farooq Awan 2017 年 11 月 7 日
How you found the value of gain?

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


Image Analyst
Image Analyst 2017 年 3 月 8 日
See this paper, which goes into great detail on the hyperspectral to RGB conversion process: http://my.ece.msstate.edu/faculty/du/JSTARS-VIS.pdf

Subhadeep Koley
Subhadeep Koley 2021 年 3 月 31 日
編集済み: Subhadeep Koley 2021 年 3 月 31 日
You can use the hypercube(__) function to read Hyperion EO-1 L1R files and also the colorize(__) method will help you to estimate color image of the Hyperion EO-1 L1R image.
% Read the L1R image (specify your L1R file name here)
hCube = hypercube('EO1H1930282003203110PY.L1R');
% Estimate the RGB image
rgbImg = colorize(hCube, 'method', 'rgb', 'ContrastStretching', true);
% Visualize the RGB image
figure
imshow(rgbImg)
title('RGB image')
NOTE: The above mentioned fetures come under Image Processing Toolbox's Hyperspectral Imaging Library support package, and can be downloaded from here. For more information on Hyperspectral Imaging Library see the documentation.

Community Treasure Hunt

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

Start Hunting!

Translated by