Could you please tell me, how I can save extracted patched from 3D image, so their original coordinates are preserved? My goal is to select some patches, so those, being combined together, form the original image. I understand that some properties e.g. origin should be changed, but I don’t understand which exactly properties should be changed (I’m just afraid to forget smth) and is there a fast way to do this without changing properties manually?
I have an image with size [512,512,512]. I am extracting patches from it using skimage function:
from skimage.util.shape import view_as_blocks img = sitk.ReadImage(name) arr = sitk.GetArrayFromImage(img) windows = view_as_blocks(arr, windows_shape) w = windows[i,j,z] w_i = sitk.GetImageFromArray(w) ### add some translation so the voxel is on its original place sitk.WriteImage(w_i,"res.nii")