Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View Image issue #148

Open
scochrane0316 opened this issue Nov 15, 2022 · 8 comments
Open

View Image issue #148

scochrane0316 opened this issue Nov 15, 2022 · 8 comments
Labels

Comments

@scochrane0316
Copy link

Hi there,

I'm new to spectral python and have come across unusual behavior when attempting to view a hyperspectral image with imshow. The information from the hdr file looks correct when I load it in, but when I try to view the image it shows up as follows:
Screenshot 2022-11-15 at 2 59 07 PM

Any ideas on what could be the issue here?
Thanks in advance!

@scochrane0316 scochrane0316 changed the title View Image showing View Image issue Nov 15, 2022
@tboggs
Copy link
Member

tboggs commented Nov 16, 2022

My guess is that either the header metadata is wrong or there is just noise in the bands you are viewing. Did you create the header or did it come from some other software?

I suggest first trying to view some other bands to see if they all look the same. Or you could just view the first principal component, since any "real" (non-noise) data would appear there.

The fact that you didn't get an error means the size of the file is consistent with the header metadata but maybe the data type is wrong. You could try a few different values and see if it makes a difference. If you post the contents of your header, I might be able to make a suggestion. The "data type" field would be particularly useful.

@scochrane0316
Copy link
Author

Thanks for the response. The header file came directly from the source (company) that the data itself came from. The data definitely shouldn't be just noise - it shows up correctly in other python packages, QGIS, and ENVI.

I tried out your suggestion of changing the data type, but the set value is correct. I tried changing the interleave, but then the file won't load at all if it's set to 'bil', 'bip', or 'bsq'. Here's a screenshot of the header metadata. Thank you!
Screenshot 2022-11-16 at 4 51 51 PM

@tboggs
Copy link
Member

tboggs commented Nov 21, 2022

I'm not sure but I've never seen an ENVI header with file type set to "TIFF" so that may be the issue. Can you tell me the exact image file size, in bytes?

@scochrane0316
Copy link
Author

The image file size is 655.2 MB

@tboggs
Copy link
Member

tboggs commented Nov 21, 2022

I need the exact size, in bytes (not MB).

@scochrane0316
Copy link
Author

655,171,014 bytes

@tboggs
Copy link
Member

tboggs commented Nov 21, 2022

It seems as though the ENVI "header" was provided for informational purposes, rather than actually reading image data from ENVI. I have never seen an ENVI file type of "TIFF" and an interleave value of "tiff" does not appear valid (based on any ENVI header file format descriptions I have seen). Furthermore, ENVI data files are supposed to be flat, binary files so according to the header, which indicates 16-bit integer value data (data type = 2), the image file size should be

2 * 1519 * 1658 * 235 = 1183695940 bytes

So my guess is that you received a self-contained TIFF file and the ENVI header is provided for metadata. If you want to process the data with the spectral module, the easiest way is probably to convert the TIFF file to ENVI format using something like gdal.

@scochrane0316
Copy link
Author

Thank you, this solved the problem once I converted the TIFF file to ENVI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants