26 print(
"Usage: " + sys.argv[0] + \
27 " <InputFileName> <OutputFileName> [Extension]")
30 inputFileName = sys.argv[1]
31 outputFileName = sys.argv[2]
33 extension = sys.argv[3]
37 fileNameFormat = outputFileName +
"-%d" + extension
42 InputImageType =
itk.Image[PixelType, Dimension]
45 reader = ReaderType.New()
46 reader.SetFileName(inputFileName)
48 OutputPixelType = itk.UC
49 RescaleImageType =
itk.Image[OutputPixelType, Dimension]
53 rescale = RescaleFilterType.New()
54 rescale.SetInput(reader.GetOutput())
55 rescale.SetOutputMinimum(0)
56 rescale.SetOutputMaximum(255)
57 rescale.UpdateLargestPossibleRegion()
59 region = reader.GetOutput().GetLargestPossibleRegion()
60 size = region.GetSize()
63 fnames.SetStartIndex(0)
64 fnames.SetEndIndex(size[2] - 1)
65 fnames.SetIncrementIndex(1)
66 fnames.SetSeriesFormat(fileNameFormat)
68 OutputImageType =
itk.Image[OutputPixelType, 2]
71 writer = WriterType.New()
72 writer.SetInput(rescale.GetOutput())
73 writer.SetFileNames(fnames.GetFileNames())