… python script trying to use numpy arrays in ‘.npy’ files as input to
color normalization, ie args for ‘itk.structure_preserving_color_normalization_filter’
flist is a list of input paths
npy_inp_img = np.load(inp_flist[0])
print(f’ npy_inp_img: dtype, shape = {npy_inp_img.dtype}, {npy_inp_img.shape}’)
npy_inp_img: dtype, shape = uint8, (1024, 1024, 3)
itk_inp_img = itk.GetImageFromArray( npy_inp_img )
print(f’ itk_inp_img: dtype, shape = {itk_inp_img.dtype}, {itk_inp_img.shape}’)
itk_inp_img: dtype, shape = <class ‘numpy.uint8’>, (1024, 1024, 3)
itk_inp_img =
itk.StructurePreservingColorNormalizationFilter[itk.Image[itk.RGBPixel[itk.UC],2]].New(itk_inp_img)
but this fails with error
File “/Users/sauer/Apr_2022_dev/tst.py”, line 184, in
itk.StructurePreservingColorNormalizationFilter[itk.Image[itk.RGBPixel[itk.UC],2]].New(itk_inp_img)
File “/Users/sauer/dl4cv/lib/python3.9/site-packages/itk/itkStructurePreservingColorNormalizationFilterPython.py”, line 636, in New
template_class.New(obj, *args, **kargs)
File “/Users/sauer/dl4cv/lib/python3.9/site-packages/itk/support/template_class.py”, line 800, in New
itk.set_inputs(self, args, kargs)
File “/Users/sauer/dl4cv/lib/python3.9/site-packages/itk/support/extras.py”, line 1209, in set_inputs
new_itk_object.SetInput(args[0])
TypeError: Expecting argument of type itkImageRGBUC2 or itkImageSourceIRGBUC2.
Additional information:
Wrong number or type of arguments for overloaded function ‘itkImageToImageFilterIRGBUC2IRGBUC2_SetInput’.
Possible C/C++ prototypes are:
itkImageToImageFilterIRGBUC2IRGBUC2::SetInput(itkImageRGBUC2 const *)
itkImageToImageFilterIRGBUC2IRGBUC2::SetInput(unsigned int,itkImageRGBUC2 const *)