Closed BlcaKHat closed 6 years ago
envi.save_image
expects either a SpyFile
or numpy.ndarray
. It looks like you are passing it a TransformedImage
object because you are calling transform
on a SpyFile
, rather than an ndarray. To save img_pc
to a file, do this instead:
envi.save_image('pcimage.hdr', img_pc.load(), dtype=np.float32)
I don't know if you are intentionally calling principal_components
on a SpyFile
object (e.g., because of system resource limitations) but note that doing so is orders of magnitude slower than doing so on a numpy array. In other words, doing this would be much faster:
data = open_image('Dun_Hyperion_Atm_Corr.hdr').load()
pc = principal_components(data)
<etc.>
Doing what I described above would also return a numpy array from the transform
call so you would not need the load
call in the arguments to the the save_image
call.
I updated the code to handle this situation in the future.
thank you @tboggs .
The code to save the file is working fine with sample data but when i am trying with hyperian (.hdr) data i am getting error![save](https://user-images.githubusercontent.com/16970999/38770866-038233d6-4037-11e8-863e-796407b525b7.png)
TypeError: load() got an unexpected keyword argument 'scale'