[Insight-users] Releasing a FileReader releases the PixelContainer of already-read images?

Zachary Pincus zpincus at stanford.edu
Sun Jan 15 23:26:55 EST 2006


Hello friends,

I've run into a troublesome issue while working on these new ITK  
wrappers.

The problem is thus: say that I create a FileReader object, pass it a  
valid file name, Update() it, and get the output image. Now, if the  
FileReader is deallocated, it seems that the PixelContainer for the  
output image is also deallocated, leaving me with an invalid image.

Is this default ITK behavior? If so, how can that behavior be turned  
off? In general (not just in the ImageFileReader/ImageSource case)  
does deallocating ITK filters also deallocate the PixelContainers of  
the images that they generate?

If this is not default behavior, I guess I have some bug-hunting to  
do in the wrappers.

Zach

PS. Here's an example from python:
 >>> import itk
 >>> infile='/Users/zpincus/Pictures/hamster.jpg'
 >>> reader=itk.ImageFileReader[itk.Image[itk.US,2]].New 
(FileName=infile)
 >>> reader.Update()
 >>> image=reader.GetOutput()
 >>> image.GetPixelContainer() != None #test for null pixel container
True
 >>> del(reader)
 >>> image.GetPixelContainer() != None
False

Thus we can see that when I deallocate the reader, something happens  
to deallocate the pixel container.


More information about the Insight-users mailing list