How to load AVIRIS datasets

14 views (last 30 days)
Cheryl S
Cheryl S on 29 Dec 2020
Edited: Jennifer Lumbres on 4 Jun 2022
Hi everyone, I have downloaded some AVIRIS datasets from https://aviris.jpl.nasa.gov/dataportal/ and have been trying to have a look at them in MATLAB. The images I obtained, however, are strange, and don't look anything like the data preview from the page. I have looked at a few resources, including
but still have not found a solution. Can anyone please shed some light on what I am doing wrong? Here is my code:
fileNameD = 'D:\Data\AVIRIS\f160620t01p00r06rdn_b\f160620t01p00r06rdn_b\f160620t01p00r06rdn_b_sc01_ort_img';
fileNameH = [fileNameD,'.hdr'];
GainFile = 'D:\Data\AVIRIS\f160620t01p00r06rdn_b\f160620t01p00r06rdn_b\f160620t01p00r06rdn_b.gain';
gainvals = importdata(GainFile);
info = envihdrread(fileNameH); %info.data_type=2 so 16-bit signed integer
X = multibandread(fileNameD,[info.lines,info.samples,info.bands],'int16',info.header_offset,info.interleave,info.byte_order,...
{'Row','Range',[4000 1 6000]}, {'Column','Range',[1 1 info.samples]});
X1 = bsxfun(@rdivide,double(X), reshape(gainvals(:,1),[1 1 length(gainvals(:,1))])); %divide by the gain to get radiance
and here is the resulting image I obtain when I plot RGB (i.e. figure, imagesc((X1(:,:,[31,20,10]))))
versus the RGB image preview @ https://aviris.jpl.nasa.gov/aviris_locator/y16_RGB/f160620t01p00r06_sc01_RGB.jpeg (note this shows the full image, while the above is only a subset)
It bears some semblance to the image but this does not seem right. I've also plotted the spectra for some pixels and it also looks strange, e.g.
I've tried this on 4 different radiance datasets so far, as well as reflectance datasets and obtained similar results. Any suggestions will be much appreciated, thank you!

Accepted Answer

Subhadeep Koley
Subhadeep Koley on 29 Dec 2020
You can use the hypercube(__) function to read AVIRIS image .hdr files.
% Read the AVIRIS image (specify your image file name here)
hCube = hypercube('jasperRidge2_R198.hdr');
% Compute RGB, CIR, and falsecolored image
rgbImg = colorize(hCube, 'method', 'rgb', 'ContrastStretching', true);
cirImg = colorize(hCube, 'method', 'cir', 'ContrastStretching', true);
fcImg = colorize(hCube, 'method', 'falsecolored', 'ContrastStretching', true);
% Visualize results
figure
tiledlayout(1, 3)
nexttile
imagesc(rgbImg)
axis image off
title('RGB image')
nexttile
imagesc(cirImg)
axis image off
title('CIR image')
nexttile
imagesc(fcImg)
axis image off
title('False-colored image')
Note: All the above mentioned fetures come under Image Processing Toolbox's Hyperspectral Imaging Library support package, and can be downloaded from here.
  5 Comments
Lahcen EDDAHBI
Lahcen EDDAHBI on 23 Mar 2022
thank you so much for the information.
i appriciate
Jennifer Lumbres
Jennifer Lumbres on 4 Jun 2022
Edited: Jennifer Lumbres on 4 Jun 2022
@Subhadeep Koley I followed your instructions and downloaded the same data. However, I'm getting an error with opening the data using hypercube:
Input:
hcube = hypercube('f160620t01p00r06rdn_b_sc01_ort_img.hdr');
Error output:
Error using hypercube>validateImageFile (line 1310)
Image file size must be 6062044800 bytes, but it is 6142384518 bytes.
Error in hypercube (line 281)
validateImageFile(imgfile, obj.Metadata);
Error in data_open_hypercube (line 1)
hcube = hypercube('f160620t01p00r06rdn_b_sc01_ort_img.hdr');
Any input will help me greatly. Thanks.
Edit: I downloaded the data through here: https://popo.jpl.nasa.gov/avcl/y16_data/f160620t01p00r06.tar.gz

Sign in to comment.

More Answers (1)

Shiqi Feng
Shiqi Feng on 1 Mar 2022
hello, I want to ask how to get .hdi file from AVIRIS datasets?

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!