22 print(
"Usage: " + sys.argv[0] +
23 " <InputFileName> <OutputFileName> [Extension]")
26 inputFileName = sys.argv[1]
27 outputFileName = sys.argv[2]
29 extension = sys.argv[3]
33 fileNameFormat = outputFileName +
"-%d" + extension
38 InputImageType =
itk.Image[PixelType, Dimension]
41 reader = ReaderType.New()
42 reader.SetFileName(inputFileName)
44 OutputPixelType = itk.UC
45 RescaleImageType =
itk.Image[OutputPixelType, Dimension]
49 rescale = RescaleFilterType.New()
50 rescale.SetInput(reader.GetOutput())
51 rescale.SetOutputMinimum(0)
52 rescale.SetOutputMaximum(255)
53 rescale.UpdateLargestPossibleRegion()
55 region = reader.GetOutput().GetLargestPossibleRegion()
56 size = region.GetSize()
59 fnames.SetStartIndex(0)
60 fnames.SetEndIndex(size[2] - 1)
61 fnames.SetIncrementIndex(1)
62 fnames.SetSeriesFormat(fileNameFormat)
64 OutputImageType =
itk.Image[OutputPixelType, 2]
67 writer = WriterType.New()
68 writer.SetInput(rescale.GetOutput())
69 writer.SetFileNames(fnames.GetFileNames())