[vtkusers] How to dump images correctly in Python

Willi Huber surfersparadise85-vtk at yahoo.com
Tue Feb 12 07:49:23 EST 2013


Hello all,

I still have the same problems.

What is the deal with vtk GetOutput(), GetOutputPort() etc.?
How long does the generator object of this GetOutput() live? Can it be dumped right after obtaining GetOutput(). How can it be dumped? 
How long does the GetOutput()-object, e.g. an image, live? How can it make it be collected by the garbage collection?

I am generating a large amount of images which have to get dumped correctly. Please advice me what to do. I think this advices are also helpful for later generations of VTK-wrapper users.

I have also problems generating only a plain image with a certain value. What I am currently doing is:

def generate_scalar_value_filled_3d_vtkImageData(spacing, origin, extent, scalar_type, scalar_value):
    import vtk

    image = vtk.vtkImageData()
    image.SetExtent([0, 0, 0, 0, 0, 0])
    image.SetOrigin(origin)
    image.SetSpacing(spacing)
    image.SetScalarType(scalar_type)
    image.AllocateScalars()

    padder = vtk.vtkImageConstantPad()
    padder.SetOutputWholeExtent(extent)
    padder.SetConstant(scalar_value)
    padder.SetInput(image)
    padder.Update()

    out = padder.GetOutput()
    # image.ReleaseData()

    return out

Whenever I call ReleaseData on the image my output is somewhat influenced. I cannot explain in which way. Can somebody explain me all the underlying structure and ideas? I am getting more and more confused from minute to minute.

Thanks in advance.

Best,
Willi




>________________________________
> Von: Willi Huber <surfersparadise85-vtk at yahoo.com>
>An: "vtkusers at vtk.org" <vtkusers at vtk.org> 
>Gesendet: 20:30 Montag, 11.Februar 2013
>Betreff: [vtkusers] How to dump images correctly in Python
> 
>
>Hello all,
>
>
>I am having serious space problems. With my program I constantly generate images and I thought the internal garbage collector of python takes care but it doesn't seem so whenever I give an image to an other filter.
>Now I am trying to delete all the unnecessary images by my own. Is there a common way to do this? I am using ReleaseData(). Is there a way to see what references a certain object?
>
>
>How is a image in vtk gernerated by a filter? Is it always a new image whenever I call GetOutput() or still the same all the time?
>
>
>Best,
>Willi
>_______________________________________________
>Powered by www.kitware.com
>
>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
>Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130212/2dae2ee3/attachment.htm>


More information about the vtkusers mailing list