Error using hypercube>​findActual​ImgFileNam​e

I'm getting "Error using hypercube>findActualImgFileName (line 1320)" when trying to load a hyperspectral image with the hypercube function. I've opened other .hdr files before with Matlab using the hypercube function without any problems. Any ideas on what is causing the hypercube>findActualImgFileName error? I guess finding the .hdr file with the given name is not a problem, but there's something in the metadata that can't be located? There are no issues when trying to open the .hdr file with ReSe GLIMPS.
As seen in the screenshot I checked that a normal .jpg image can be found in the current folder, and also tested the hypercube with the 'indian_pines.dat' image that comes with Matlab to check if the hypercube is working as it should. No errors so far. Then in the third section I try to load my own hyperspectral image and that's when I get an error about finding the actual image file name.

 Risposta accettata

Walter Roberson
Walter Roberson il 14 Dic 2021
Modificato: Walter Roberson il 14 Dic 2021
"Read ENVI format data into the workspace by specifying a header file that contains information about hyperspectral data. The associated ENVI binary data file must be stored in the same folder as the ENVI header file."
and see https://www.mathworks.com/help/images/ref/hypercube.html#d123e305031 which indicates that it expects a .dat file or .L1R file when you use a .hdr file.
I seem to recall that .hdr files have the name of the corresponding image data stored inside them, so I suspect the file extension is not completely important. However, I suspect that the .hdr file is saying that the image data is stored in a file that has the same name but no extension at all. In particular, I do not think the .hdr file is referring the the .hyspex file.

4 Commenti

This is the information found in the .hdr file when viewing it with notepad:
ENVI
description = {
Frameperiod = 18000
Integration time = 15000
Binning = 1
Number of frames = 7939
Aperture size = 0.01000000000000000021
dw = 1
EQ = 0
Lens = 1
HSNR = 0
CalibAvailable = 0
Number of background = 200
Pixelsize x = 0.00016000000000000001
Pixelsize y = 0.00032000000000000003
ID = VNIR_1800_SN00841
Comment =
Serialnumber = 841
Scanningmode = Ground
}
samples = 1800
lines = 7939
bands = 186
header offset = 8044544
data ignore value = 65535
data type = 12
interleave = bil
default bands = {75,46,19}
byte order = 0
wavelength units = nm
wavelength = { ((lots of wavelenghts here))}
Are you saying I can insert a line referencing the corresponding .hyspex file and then Matlab will be able to find it?
Checking on the previous project where i used .hdr I don't seem have .dat or .L1R in the same folder, so I guess it doesn't have to be those file formats. But I had a corresponding .img file, and not .hyspex. Looking at the information in the .hdr file for that project I don't see anything that's referencing the .img file.
It looks like the image file extension might not matter if you use the two-parameter form, hypercube(img, hdr)
When you pass in a .hdr file, hypercube() will look for a file with the same name as the .hdr but no extension; then it will look for a .dat file, then a .img file, and then a .L1R file. If it does not find any of those then it will fail with the message you showed.
If you only want the header information then you can potentially use enviinfo() -- but if you want to read the image then you need the image data.
It works when using two arguments, thank you:)
Curiously enough it only works when I switch places for the arguments. Meaning hypercube("hyspex-file", "hdr-file") gives an error, but hypercube("hdr-file", "hyspex-file") runs.
if I try
hcube = hypercube("A1_VNIR_1800_SN00841_15000us_2021-07-12T140630_raw.hyspex", "A1_VNIR_1800_SN00841_15000us_2021-07-12T140630_raw.hdr");
I get:
Error using hypercube (line 400)
Input file format must be ENVI, TIFF, or NITF.
Error in tests (line 13)
hcube = hypercube("A1_VNIR_1800_SN00841_15000us_2021-07-12T140630_raw.hyspex",
"A1_VNIR_1800_SN00841_15000us_2021-07-12T140630_raw.hdr");
but when I try
hcube = hypercube("A1_VNIR_1800_SN00841_15000us_2021-07-12T140630_raw.hdr", "A1_VNIR_1800_SN00841_15000us_2021-07-12T140630_raw.hyspex");
There's no error and I'm able to use hyperspectralViewer(hcube) and view the image.
Interestingly, there is specific code in hypercube() to detect if the parameter order has been reversed by the user by checking the first parameter for ".hdr". I did not happen to check whether that was done before or after the file format was checked.

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by