spectralpython / spectral

Python module for hyperspectral image processing
MIT License
571 stars 139 forks source link

how do i see all the bands while opening the (.hdr) envi file. and choose greyscale or RGB. #75

Closed BlcaKHat closed 6 years ago

BlcaKHat commented 6 years ago

I want to open the .hdr file but before it i want to open the band list and and option to choose greyscale or RGB. currently, I am opening like this. please help, I am working with Remote sensing guys so i am not getting any help from them.

tboggs commented 6 years ago

If the .hdr file contains the band information, then there is no way to get the band information without opening it. If you don't have the data file present, you can use envi.read_envi_header to get a dict of parameters. But opening the data file along with the header (using envi.open) shouldn't be an issue because it doesn't actually read the data until you access it.

BlcaKHat commented 6 years ago

I am loading the image in img. with this. img = envi.open('Dun_Hyperion_Atm_Corr.hdr','Dun_Hyperion_Atm_Corr')

and can view it by this . view = imshow(img,(29,19,9)) but what if i want to see all the bands before view. means, if i could choose the bands present in the img and i can open in RGB or greyscale.

tboggs commented 6 years ago

Band information is in the img.bands attribute. You can select any three bands to view in RGB. If you want a greyscale image (e.g., band 30) you can do this:

view = spy.imshow(img, (30,))

or this:

view = spy.imshow(img.read_band(30))
BlcaKHat commented 6 years ago

Thanx for your reply. But is there any way to find all the bands ? I am trying to make a GUI to list all the bands. and then I could select the bands for R,G,B or one band for greyscale. If somehow I get all the bands I could select them in GUI. because user won't know all the bands which will load into GUI.

tboggs commented 6 years ago

As I said before, the band information is information is in the img.bands attribute. So for example, to get all the center wavelengths, you would use img.bands.centers.

BlcaKHat commented 6 years ago

this is giving the wavelengths. can I put it together with band number like this ?. please write an example as before. please have a look first_o

BlcaKHat commented 6 years ago

sorry to disturb. I think i got it . I will ask again if needed. Thanks @tboggs