MATLAB Answers

How to load AVIRIS datasets

21 views (last 30 days)
Cheryl S
Cheryl S on 29 Dec 2020
Commented: Cheryl S on 30 Dec 2020
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.
  3 Comments
Cheryl S
Cheryl S on 30 Dec 2020
Oh, you're right, I did as you suggested and it works now! I also combined enviinfo with multibandread to extract only a subset of the image and it works as well! Must be an issue with my original enviinfo.m file. Thank you very much for your help!

Sign in to comment.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!