Forum

Author Topic: how to create tiff input from hyperspectral array  (Read 3046 times)

Rosy

  • Newbie
  • *
  • Posts: 21
    • View Profile
how to create tiff input from hyperspectral array
« on: October 03, 2017, 04:13:35 PM »
Hi,

I have 3d array (python) containing hyperspectral data created from raw data. Two dimensions are the image space and the 3rd dimension are different bands. I need to create a single-page multi-channel (each channel containing one band image) tiff file as the input for Agisoft, but I always get results of multi-page multi-band tif.

Does any one know how to create the correct tiff file using python?Any recommendation of softwares, packages or parameter setting will be appreciated.




tuffi

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: how to create tiff input from hyperspectral array
« Reply #1 on: October 04, 2017, 12:00:59 PM »
Hi,
do you have some example of the multiarray create in phyton? Do you have hyperspectral datacube orthocorrected jet?

Gall

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Re: how to create tiff input from hyperspectral array
« Reply #2 on: October 04, 2017, 04:45:33 PM »
I had a similar issue for one of my Python processes (though not Photoscan related) and the only way I found to create a multi-channel (more than 4 channels) was to use the tifffile module by Christoph Gohlke.
http://www.lfd.uci.edu/~gohlke/pythonlibs/#tifffile

Code: [Select]
# Here data shape is (height, width, depth)
tifffile.imsave(filename, data, compress=5, planarconfig='contig')

In this example, the compress argument enable the lossless zlib compression (remove it for no compression at all). The planarconfig value is required to save a (height, width, depth) image as tifffile usually handles (sample, height, width) .
However, tifffile does not handle the saving of SubIFDs, ExifIFD, or GPSIFD tags so if you need to write them you will have to use pyexiv2 or py3exiv2 (depending on your Python version).

This module does not have an online documentation but you can check the doc strings of tifffile.imsave and tifffile.TiffWritter.save, in IPython or similar, for more informations and/or to tweak the above example.

Rosy

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: how to create tiff input from hyperspectral array
« Reply #3 on: October 11, 2017, 12:55:19 PM »
Hi Gall,

The tifffile module from Christoph Gohlke is exactly what I used to create the multi-channel tiff from my 3D array. But they are  multi-pages instead of the single-page as required by Agisoft. I still couldn't generate single-page tiff which one FID contains multiple images. How should I set those paramters? It seems some of them are also related with each other.

Any one could help, please?