Hello,
I have some trouble with setting input ndarray to otbApplication :
Let's consider "image" is a large tiff
>pil_image = PILImage.open(image)
>np_image = np.asarray(pil_image)
np_image is now a 2d array.
now :
>sar_calibration = otbApplication.Registry.CreateApplication("SARCalibration")
>sar_calibration.SetImageFromNumpyArray("in", np_image)
>sar_calibration.Execute()
Giving this error in the shell:
File "/home/massea/OTB-6.2.0-Linux64/lib/python/otbApplication.py", line
1116, in SetImageFromNumpyArray
self.SetImageFromUInt16NumpyArray_(paramKey, npArray)
File "/home/massea/OTB-6.2.0-Linux64/lib/python/otbApplication.py", line 959,
in SetImageFromUInt16NumpyArray_
def SetImageFromUInt16NumpyArray_(self, *args): return
_otbApplication.Application_SetImageFromUInt16NumpyArray_(self, *args)
TypeError: Array must have 3 dimensions. Given array has 2 dimensions
So i transform my array like that:
>np_image2 = np.reshape(np_image, [np_image.shape[0], np_image.shape[1], 1])
And a new error appears:
File "/media/massea/DATA/Workspace/orthoS1/orthoS1/Processing.py", line
36, in s1_calibration_with_numpy
sar_calibration.SetImageFromNumpyArray("in", input_array)
File "/home/massea/OTB-6.2.0-Linux64/lib/python/otbApplication.py", line
1101, in SetImageFromNumpyArray
raise ValueError( "(len(npArray.shape) == 3)\n"
ValueError: (len(npArray.shape) == 3)
Input array given is of 3 dimension.
SetImageFromNumpyArray create ImageIO from otbImage and thus demands a 2d
array.
you can either provide an 2d numpy array or use
SetVectorImageFromNumpyArray depending on your application.
Do you have any idea to resolve this problem?
Thanks
Antoine
--
--
Check the OTB FAQ at
http://www.orfeo-toolbox.org/FAQ.html
You received this message because you are subscribed to the Google
Groups "otb-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/otb-users?hl=en
---
You received this message because you are subscribed to the Google Groups
"otb-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.