[Insight-users] using itkStreamingImageFilter with python

Miller, James V (Research) millerjv at crd.ge.com
Tue Mar 1 13:00:30 EST 2005


Jon, 

I don't think any of the ITK readers support streaming sections of an 
image from disk. All the readers read the entire image into memory. Once
in memory, sections of the image can be streamed for filtering.

This is section of the IO mechanism that still needs work.  It would be great to be able to tell a reader to just to input a section of an image and each 
ImageIO object would do the right thing.  It gets tricky with compressed
file formats but usually compressed formats allow you to get a row at a time
that could then be cropped as needed by the request.

Jim



-----Original Message-----
From: insight-users-bounces at itk.org
[mailto:insight-users-bounces at itk.org]On Behalf Of Jon Moody
Sent: Tuesday, March 01, 2005 11:30 AM
To: Insight Users
Subject: [Insight-users] using itkStreamingImageFilter with python


Hi,

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()  )

writer.Update()


--

Thanks,

Jon




_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list