[Insight-users] using itkStreamingImageFilter with python

Jon Moody jonathan at molecularimaging.com
Tue Mar 1 11:29:39 EST 2005


I'm trying to downsample a large CT file (4.5 GB) which is too large to
reside in memory, by combining itkStreamingImageFilter with a single
level of itkRecursiveMultiResolutionPyramidImageFilter and a shrink
factor 2.

Since I want to do it in Python, I wrapped itkStreamingImageFilter and
itkImageRegionMultidimensionalSplitter.  The python script (see below)
works for small image files, but for a big CT file (4.5 GB), it quits
with "MetaImage: Read: Cannot open data file" or "nrrdRead: trouble
reading NRRD file; file too large" (I tried both MetaImage and NrrdIO
input file formats).

I couldn't find many examples of using itkStreamingImageFilter (just a
couple of tests in Testing/Code/BasicFilters).  Is there a way to get
this script to work?

# using itk to down sample a large uCT image

from InsightToolkit import *

from sys import argv

inFile          = argv[1]
outFile         = argv[2]
numberOfStreams = int(argv[3])

reader = itkImageFileReaderSS3_New()
writer = itkImageFileWriterUS3_New()

reader.SetFileName( inFile )
writer.SetFileName( outFile )

inputCast  = itkCastImageFilterSS3F3_New()
filter  = itkRecursiveMultiResolutionPyramidImageFilterF3F3_New()
outputCast = itkRescaleIntensityImageFilterF3US3_New()

outputCast.SetOutputMinimum(      0  )
outputCast.SetOutputMaximum(  65535  )

numberOfLevels     = 1
shrinkFactor       = 2

filter.SetNumberOfLevels( numberOfLevels )
filter.SetStartingShrinkFactors( shrinkFactor )

inputCast.SetInput( reader.GetOutput() )
filter.SetInput(  inputCast.GetOutput() )

stream = itkStreamingImageFilterF3F3_New()
splitter = itkImageRegionMultidimensionalSplitter3_New()
stream.SetInput(  filter.GetOutput(0)  )
stream.SetNumberOfStreamDivisions( numberOfStreams )
stream.SetRegionSplitter( splitter.GetPointer() )
outputCast.SetInput( stream.GetOutput() )

writer.SetInput(      outputCast.GetOutput()  )





More information about the Insight-users mailing list