I am attempting to follow the SimpleITK2020 (Python) tutorial but with F#.
Part of the code in the “Accessing Pixels and Slicing” section is the following:
logo_copy[115:190, 0:height] = logo_copy[190:115:-1, 0:height]
plt.imshow(sitk.GetArrayViewFromImage(logo_copy))
What is the equivalent of:
GetArrayViewFromImage
and GetArrayFromImage
in C# and
the array slicing logo_copy[115:190, 0:height] = logo_copy[190:115:-1, 0:height]
in C#?
dchen
(Dave Chen)
November 14, 2024, 1:08pm
2
For C# the following example shows how you can get a pointer to the image buffer and copy out the pixels:
https://simpleitk.readthedocs.io/en/master/link_CSharp_docs.html
I don’t think there’s any way of do the type of image slicing in C#.
blowekamp
(Bradley Lowekamp)
November 14, 2024, 2:18pm
3
zivy
(Ziv Yaniv)
November 14, 2024, 2:18pm
4
Hello @general_rishkin ,
With respect to the slicing flipping and pasting which is shown in that example, you will need to use the filters directly ExtractImageFilter , FlipImageFilter , and PasteImageFilter . Something along the lines of the following Python code:
extracted_sub_image = sitk.Extract(logo_copy, size=[75, height], index=[115, 0])
extracted_sub_image_flipped = sitk.Flip(extracted_sub_image, flipAxes=[True, False])
res = sitk.Paste(
destinationImage=logo_copy,
sourceImage=extracted_sub_image_flipped,
sourceSize=extracted_sub_image_flipped.GetSize(),
sourceIndex=[0] * extracted_sub_image_flipped.GetDimension(),
destinationIndex=[115, 0],
)
1 Like