<html><body><div style="color:#000; background-color:#fff; font-family:tahoma, new york, times, serif;font-size:10pt"><div><span>Thanks a lot David,</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>One last thing. How do I delete an VTK object? In python I can't call Delete(). And how can I be sure the object is deleted? I know of DebugOn() and the vtkDebugMacro but how can it be printed? Whenever I am trying this little example in ipython:</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px;
 font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>------</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>import vtk</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">a = vtk.vtkObject()</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">a.DebugOn()</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">del a</div><div
 style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">------</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;">nothing can be seen. Is the object deleted or can't I see the output? How can I make te output visible?</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>Cheers,</span></div><div style="color: rgb(0, 0, 0); font-size:
 13px; font-family: tahoma, 'new york', times, serif; background-color: transparent; font-style: normal;"><span>Wili</span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;">  <div style="font-family: tahoma, 'new york', times, serif; font-size: 10pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">Von:</span></b> David Gobbi &lt;david.gobbi@gmail.com&gt;<br> <b><span style="font-weight: bold;">An:</span></b> Willi Huber &lt;surfersparadise85-vtk@yahoo.com&gt; <br><b><span style="font-weight: bold;">CC:</span></b> "vtkusers@vtk.org" &lt;vtkusers@vtk.org&gt; <br> <b><span style="font-weight: bold;">Gesendet:</span></b> 15:17 Dienstag, 12.Februar 2013<br> <b><span style="font-weight: bold;">Betreff:</span></b> Re: [vtkusers] How to dump images
 correctly in Python<br> </font> </div> <br>Hi Willi,<br><br>An output exists for as long as its generator exists.&nbsp; Likewise, the<br>generator exists for as long as the output exists.&nbsp; As long as your<br>program is making use of one or the other, neither will be freed.&nbsp; So<br>what you should do is copy the output into a new data object:<br><br>o = vtkImageData()<br>o.DeepCopy(f.GetOutput())<br><br>After you do that, you can delete the original output and the entire<br>pipeline that it was connected to.&nbsp; The new output (i.e. the copy) can<br>be used as input to a new pipeline.&nbsp; You can also try ShallowCopy()<br>instead of DeepCopy(), but after ShallowCopy the original output and<br>its copy share the same data array, so after ShallowCopy you should<br>call ReleaseData on the original output.<br><br>By the way, this is not wrapper-specific.&nbsp; It is exactly the same for<br>VTK in C++.<br><br> - David<br><br>On Tue, Feb 12, 2013
 at 5:49 AM, Willi Huber<br>&lt;<a ymailto="mailto:surfersparadise85-vtk@yahoo.com" href="mailto:surfersparadise85-vtk@yahoo.com">surfersparadise85-vtk@yahoo.com</a>&gt; wrote:<br>&gt; Hello all,<br>&gt;<br>&gt; I still have the same problems.<br>&gt;<br>&gt; What is the deal with vtk GetOutput(), GetOutputPort() etc.?<br>&gt; How long does the generator object of this GetOutput() live? Can it be<br>&gt; dumped right after obtaining GetOutput(). How can it be dumped?<br>&gt; How long does the GetOutput()-object, e.g. an image, live? How can it make<br>&gt; it be collected by the garbage collection?<br>&gt;<br>&gt; I am generating a large amount of images which have to get dumped correctly.<br>&gt; Please advice me what to do. I think this advices are also helpful for later<br>&gt; generations of VTK-wrapper users.<br>&gt;<br>&gt; I have also problems generating only a plain image with a certain value.<br>&gt; What I am currently doing is:<br>&gt;<br>&gt;
 def generate_scalar_value_filled_3d_vtkImageData(spacing, origin, extent,<br>&gt; scalar_type, scalar_value):<br>&gt;&nbsp; &nbsp;  import vtk<br>&gt;<br>&gt;&nbsp; &nbsp;  image = vtk.vtkImageData()<br>&gt;&nbsp; &nbsp;  image.SetExtent([0, 0, 0, 0, 0, 0])<br>&gt;&nbsp; &nbsp;  image.SetOrigin(origin)<br>&gt;&nbsp; &nbsp;  image.SetSpacing(spacing)<br>&gt;&nbsp; &nbsp;  image.SetScalarType(scalar_type)<br>&gt;&nbsp; &nbsp;  image.AllocateScalars()<br>&gt;<br>&gt;&nbsp; &nbsp;  padder = vtk.vtkImageConstantPad()<br>&gt;&nbsp; &nbsp;  padder.SetOutputWholeExtent(extent)<br>&gt;&nbsp; &nbsp;  padder.SetConstant(scalar_value)<br>&gt;&nbsp; &nbsp;  padder.SetInput(image)<br>&gt;&nbsp; &nbsp;  padder.Update()<br>&gt;<br>&gt;&nbsp; &nbsp;  out = padder.GetOutput()<br>&gt;&nbsp; &nbsp;  # image.ReleaseData()<br>&gt;<br>&gt;&nbsp; &nbsp;  return out<br>&gt;<br>&gt; Whenever I call ReleaseData on the image my output is somewhat influenced. I<br>&gt; cannot
 explain in which way. Can somebody explain me all the underlying<br>&gt; structure and ideas? I am getting more and more confused from minute to<br>&gt; minute.<br>&gt;<br>&gt; Thanks in advance.<br>&gt;<br>&gt; Best,<br>&gt; Willi<br>&gt;<br>&gt;<br>&gt; ________________________________<br>&gt; Von: Willi Huber &lt;<a ymailto="mailto:surfersparadise85-vtk@yahoo.com" href="mailto:surfersparadise85-vtk@yahoo.com">surfersparadise85-vtk@yahoo.com</a>&gt;<br>&gt; An: "<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>" &lt;<a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>&gt;<br>&gt; Gesendet: 20:30 Montag, 11.Februar 2013<br>&gt; Betreff: [vtkusers] How to dump images correctly in Python<br>&gt;<br>&gt; Hello all,<br>&gt;<br>&gt; I am having serious space problems. With my program I constantly generate<br>&gt; images and I thought the internal garbage collector of python takes
 care but<br>&gt; it doesn't seem so whenever I give an image to an other filter.<br>&gt; Now I am trying to delete all the unnecessary images by my own. Is there a<br>&gt; common way to do this? I am using ReleaseData(). Is there a way to see what<br>&gt; references a certain object?<br>&gt;<br>&gt; How is a image in vtk gernerated by a filter? Is it always a new image<br>&gt; whenever I call GetOutput() or still the same all the time?<br>&gt;<br>&gt; Best,<br><br><br> </div> </div> </blockquote></div>   </div></body></html>