Hello community,
I don’t manage to create an arbitrary pixel from a numpy scalar. I would like to transform the numpy scalar to a pixel, using fill if pixel has multiple modalities
px_type = itk.template(itk_image)[1][0]
px_trait = itk.NumericTraits[px_type]
if self.background_value == 'max':
background_value = px_trait.max()
elif self.background_value == 'min':
background_value = px_trait.min()
elif np.isscalar(self.background_value):
# How to do here ??
background_value = np.ndarray.item(np.asanyarray(self.background_value).astype(np_image.dtype))
else:
raise NameError('background_value type not recognized. Should be min, max or a scalar.')
# resampler
resampler = itk.ResampleImageFilter.New(Input=itk_image)
resampler.SetDefaultPixelValue(background_value)
I guess I’m missing something, any help ?
Thanks,
Y.