The MATLAB hyperspectral toolbox add-on to the Image Processing Toolbox seems pretty new and correspondingly buggy.
1) It appears incapable of reading in an image with an ENVI image with header, for example the command
>> hcube_mat = hypercube('AVIRIS_NG_refCube.img','AVIRIS_NG_refCube.hdr');
generates the following errors
Error using enviinfo (line 53)
File type number: char not supported.
Error in hypercube>getMetaforImg (line 1227)
header = enviinfo(imgFile);
Error in hypercube (line 304)
obj.Metadata = getMetaforImg(hdrfile, 'envi');
2) The Spectral Library capability seems a mess. I see no way of reading in a new spectral library other than the default ECOSTRESS library. Am I missing something here with regards to reading in my own ENVI spectral library?

 채택된 답변

William
William 2021년 10월 21일

0 개 추천

Thanks for your help with this issue. I'm attaching a *.mat file with those 3 variables.

추가 답변 (1개)

Subhadeep Koley
Subhadeep Koley 2021년 10월 6일

1 개 추천

1) The error is originating from line number 53 of "enviinfo.m".
It seems that you have one local custom function in the name of "enviinfo.m", which is conflicting with the Hyperspectral Imaging Library's own enviinfo(__) function. There is no runnable code in line 53 of Hyperspectral Imaging Library's enviinfo(__) function. You can verify it by looking at the function defination of Hyperspectral Imaging Library's enviinfo(__) function.
Either rename/delete your local custom "enviinfo.m" function or remove it from MATLAB path, and then try again.
rmpath('thePathWhereCustomEnviinfoResides')
2) You can use the Hyperspectral Imaging Library's enviinfo(__) function to read metadata from your header file (.hdr file), and then use multibandread(_) to read the binary file containing your ENVI spectral library.
E.g.,
% Read the header file
info = enviinfo('enviSpectralLibrary.sli.hdr');
% Read the binary data file
lib = multibandread('enviSpectralLibrary.sli',[info.Height, info.Width, info.Bands],...
info.DataType, info.HeaderOffset, info.Interleave, info.ByteOrder);
Hope this helps!

댓글 수: 6

William
William 2021년 10월 8일
Thanks I did, in fact, have a third party enviinfo.m file and renaming it allowed the new hypercube function to work and likewise the steps for reading in the spectral library worked... THANKS!
William
William 2021년 10월 8일
Working with this a bit more, I see that the spectra read in from the ENVI spectral library via the suggested procedure are just read in as array. That's fine as far as it goes, but is there any mechanism for getting it into the structure format that your toolbox seems to want other than laboriously entering in 15 fields for each entry?
@William Most of the Field Names returned by readEcostressSig(_) are optional extra information. Only Wavelength and Reflectance fields are required to perform spectral matching.
Therefore, you can rearrange the custom ENVI spectral library as a 1-by-K structure array, where K is the number of spectrum present in your custom ENVI spectral library. Each element of the1-by-K structure array must contain at least two fields i.e., Wavelength and Reflectance. Then you can call spectralMatch with the syntax below,
scoreMap = spectralMatch(customEnviLibStructure, hCube); % Here hCube is a hypercube object
Consequently, entering in 15 fields for each entry is not necessary for performing spectral matching.
William
William 2021년 10월 20일
Thanks for the answer on that, but I'm still getting erroneous results. I build a spectral library with the two fields of Wavelength and Reflectance... putting those in for each entry in the library (and Wavelength is a one column vector that I replicate for each entry and each entry has its number of bands (for rows) and number of reflectance spectra vectors for each Reflectance entry. Then doing a match of a vector against that library with the command:
SAM_Values = spectralMatch(Fe2Fe3Mins2,sp202,wav,'Method','sam');
where Fe2Fe3Mins2 is the library structure, sp202 is a single column reflectance spectrum of the "unknown" and wav is the wavelength. I get a value for each entry, but they're one of two numbers 3.01 or 0.13 for each entry, so that's clearly not right. Any ideas?
Subhadeep Koley
Subhadeep Koley 2021년 10월 21일
@William, Is it possible for you to attach the Fe2Fe3Mins2, sp202, and wav variables as a .mat file here?
Without the actual data, it's difficult to comment on the issue.
William
William 2021년 10월 26일
I thought I responded to this, but maybe it didn't go out:
Thanks for your help with this issue. I'm attaching a *.mat file with those 3 variables.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Hyperspectral Image Processing에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2021년 10월 4일

댓글:

2021년 10월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by