Hi, i am new to the itk package. Would you have time to do a sample code on Resampling image in python?
i got the c++ version here : https://itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter
My need is to reshape the image and plot a histogram between two reshaped images.
Thanks in advance.
Welcome to ITK, @SantaHub!
Here are a few resampling examples in Python:
See the Quick Start Guide on how convert the image pixel buffer to a numpy array. A histogram can be visualized from the array with matplotlib.
However, I would not expect a large difference in the histogram unless there is extreme deformation in the transform.
How would you do this for a vector image?
I think this would use something like the following:
Dimension = 2
PixelType = itk.RGBPixel[itk.UC]
ImageType = itk.Image[PixelType, Dimension]
the problem I think is that I want to do this in simpleITK, because otherwise I am mixing things together in a convoluted way, and having tried the above I get a type error.
either I need an equivalent SimpleITK version for RGB, or a way to convert a composite sitk transform to itk transform…
I have discovered this :
# Extract first three channels of joined image (assuming RGB)
select = sitk.VectorIndexSelectionCastImageFilter()
channel1_image = select.Execute(joined_image, 0, sitk.sitkUInt8)
channel2_image = select.Execute(joined_image, 1, sitk.sitkUInt8)
channel3_image = select.Execute(joined_image, 2, sitk.sitkUInt8)
I found that I can resample each component individually.
You should open a new questions, but SimpleITK’s Resample working with RGB or vector pixel types by default, so there is not need to run in on a per component basis.
@blowekamp Apologies for not making a new question, I will do that.