Stacking Z dimension images using SimpleITK

I used a similar method like you suggested and it resulted in no improvement.

Code:

import SimpleITK as sitk #1

raw_img = "resampled_image.tif"

raw_img_sitk = sitk.ReadImage(raw_img, sitk.sitkFloat32) #2
raw_img_sitk_arr = sitk.GetArrayFromImage(raw_img_sitk) #3

transformed = sitk.RescaleIntensity(raw_img_sitk, 0, 255) #1
transformed = sitk.LiThreshold(transformed,0,1) #2
head_mask = transformed

shrinkFactor = 4 #1
inputImage = raw_img_sitk

inputImage = sitk.Shrink( raw_img_sitk, [ shrinkFactor ] * inputImage.GetDimension() ) #2
maskImage = sitk.Shrink( head_mask, [ shrinkFactor ] * inputImage.GetDimension() ) #3

bias_corrector = sitk.N4BiasFieldCorrectionImageFilter() #4

corrected = bias_corrector.Execute(inputImage, maskImage) #5

log_bias_field = bias_corrector.GetLogBiasFieldAsImage(raw_img_sitk) #1
corrected_image_full_resolution = raw_img_sitk / sitk.Exp( log_bias_field ) #2

out_path =  "field_corrected_image.tif"

# Cast the pixel type to float
corrected_float = sitk.Cast(corrected_image_full_resolution, sitk.sitkFloat32)

out_path = "corrected_resampled_image.tif"
sitk.WriteImage(corrected_float, out_path)

image

I was reading through Optical flow to fix “artifacts” that comes-up after tile merging and it looked nice. You have any thoughts or other algorithms to point to? Registration using optical flow — skimage 0.23.2 documentation @dzenanz