I am working with 3D images(300) of size (128x128x128). I want to extract the image area/an array of the image intensities (remove the background), do some transformation, and plug the transformed image intensities back on the original image (so that it has the same shape as before 128x128x128). Is it possible to do this with sitk?
Generally speaking, yes. As always, this depends on what exactly you want to do.
Example below adds 100 to all foreground pixels (foreground obtained via Otsu thresholding):
import SimpleITK as sitk
file_name = "training_001_ct.mha"
image = sitk.ReadImage(file_name)
mask = sitk.Cast(sitk.OtsuThreshold(image, 0, 1), image.GetPixelID())
sitk.Show(image, "original")
sitk.Show(image + mask*100, "adding 100 to foreground")