20 parser = argparse.ArgumentParser(description=
"Resample Segmented Image.")
21 parser.add_argument(
"input_image")
22 parser.add_argument(
"spacing_fraction", type=float)
23 parser.add_argument(
"sigma_fraction", type=float)
24 parser.add_argument(
"output_image_file_label_image_interpolator")
25 parser.add_argument(
"output_image_file_nearest_neighbor_interpolator")
26 args = parser.parse_args()
28 input_image = itk.imread(args.input_image)
32 input_spacing = itk.spacing(input_image)
33 output_spacing = [s * args.spacing_fraction
for s
in input_spacing]
34 resize_filter.SetOutputSpacing(output_spacing)
36 input_size = itk.size(input_image)
38 int(s * input_spacing[dim] / args.spacing_fraction)
39 for dim, s
in enumerate(input_size)
41 resize_filter.SetSize(output_size)
44 sigma = [s * args.sigma_fraction
for s
in output_spacing]
45 gaussian_interpolator.SetSigma(sigma)
46 gaussian_interpolator.SetAlpha(3.0)
47 resize_filter.SetInterpolator(gaussian_interpolator)
49 itk.imwrite(resize_filter, args.output_image_file_label_image_interpolator)
54 resize_filter.SetInterpolator(nearest_neighbor_interpolator)
56 itk.imwrite(resize_filter, args.output_image_file_nearest_neighbor_interpolator)