Dear all,<div><br></div><div>an anyone tried this before for a specific given plane of vtkImageReslice type?</div><div><br></div><div>Any help is appreciated!</div><div><br></div><div><br></div><div>Many thanks,</div><div>

Joao</div><div><br></div><div><br></div><div><br><br><div class="gmail_quote">On 30 July 2012 13:17, João Domingos <span dir="ltr">&lt;<a href="mailto:joao.sousa.domingos@gmail.com" target="_blank">joao.sousa.domingos@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<div><br></div><div>I was trying to use the PolyDataToImageData example (<a href="http://www.vtk.org/Wiki/VTK/Examples/PolyData/PolyDataToImageData" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/PolyData/PolyDataToImageData</a>) to get the intersection of a vtkPolyData with a plane in a given orientation, but to start with, I cannot even run the example in python. With the code below I get a TypeError: no overloads of SetInput() take 0 arguments</div>


<div><br></div><div><br></div><div><div><span style="white-space:pre-wrap">                </span>#--------------------------------------------------------------------------------</div><div><span style="white-space:pre-wrap">                </span># Create LV segmentation image where the foreground voxels are 1 and the background voxels are 0. Internally vtkPolyDataToImageStencil is utilized. The resultant image is saved to disk</div>


<div><span style="white-space:pre-wrap">                </span>spacing = np.zeros(3)</div><div><br></div><div><span style="white-space:pre-wrap">                </span>whiteImage = vtk.vtkImageData()</div><div><span style="white-space:pre-wrap">                </span>bounds = self.dsurf.dense_representation_grid.GetBounds()</div>


<div><span style="white-space:pre-wrap">                </span>spacing[0] = 0.0960<span style="white-space:pre-wrap">                </span># desired volume spacing (.mha info): ElementSpacing = 0.0960 0.0968 0.0726</div>
<div><span style="white-space:pre-wrap">                </span>spacing[1] = 0.0968</div><div><span style="white-space:pre-wrap">                </span>spacing[2] = 0.0726</div><div><span style="white-space:pre-wrap">                </span>whiteImage.SetSpacing(spacing)</div>


<div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">                </span># Compute dimensions:<span style="white-space:pre-wrap">        </span></div>
<div><span style="white-space:pre-wrap">                </span>dim = []</div><div><span style="white-space:pre-wrap">                </span>dim.append((bounds[1] - bounds[0])/spacing[0])</div><div><span style="white-space:pre-wrap">                </span>dim.append((bounds[3] - bounds[2])/spacing[1])</div>


<div><span style="white-space:pre-wrap">                </span>dim.append((bounds[5] - bounds[4])/spacing[2])</div><div><br></div><div><span style="white-space:pre-wrap">                </span>whiteImage.SetDimensions(dim)</div>
<div><span style="white-space:pre-wrap">                </span>whiteImage.SetExtent(0, dim[0]-1,0,dim[1]-1,0,dim[2]-1)</div><div><br></div><div><span style="white-space:pre-wrap">                </span>origin = np.zeros(3)</div>
<div><br></div><div><span style="white-space:pre-wrap">                </span>origin[0] = bounds[0] + spacing[0] / 2;</div><div>  <span style="white-space:pre-wrap">                </span>origin[1] = bounds[2] + spacing[1] / 2;</div>
<div>  <span style="white-space:pre-wrap">                </span>origin[2] = bounds[4] + spacing[2] / 2;</div><div> <span style="white-space:pre-wrap">                </span>whiteImage.SetOrigin(origin);</div><div>
<br></div><div><span style="white-space:pre-wrap">                </span>whiteImage.SetScalarTypeToUnsignedChar()</div><div><span style="white-space:pre-wrap">                </span>whiteImage.AllocateScalars();</div>
<div><br></div><div><span style="white-space:pre-wrap">                </span>inval = 255;</div><div>  <span style="white-space:pre-wrap">                </span>outval = 0;</div><div>  <span style="white-space:pre-wrap">                </span>count = whiteImage.GetNumberOfPoints();</div>


<div>  <span style="white-space:pre-wrap">                </span>for i in range(0,count):</div><div>    <span style="white-space:pre-wrap">                        </span>whiteImage.GetPointData().GetScalars().SetTuple1(i, inval);</div>
<div><br></div><div><span style="white-space:pre-wrap">                </span># polygonal data --&gt; image stencil:</div><div><span style="white-space:pre-wrap">                </span>pol2stenc = vtk.vtkPolyDataToImageStencil()</div>
<div><span style="white-space:pre-wrap">                </span>pol2stenc.SetInput(self.dsurf.dense_representation_grid)</div><div><span style="white-space:pre-wrap">                </span>pol2stenc.SetOutputOrigin(origin);</div>
<div> <span style="white-space:pre-wrap">                </span>pol2stenc.SetOutputSpacing(spacing);</div><div>  <span style="white-space:pre-wrap">                </span>pol2stenc.SetOutputWholeExtent(whiteImage.GetExtent());</div>
<div> <span style="white-space:pre-wrap">                </span>pol2stenc.Update();</div><div><br></div><div><span style="white-space:pre-wrap">                </span># cut the corresponding white image and set the background:</div>
<div><span style="white-space:pre-wrap">                </span>imgstenc = vtk.vtkImageStencil</div><div><span style="white-space:pre-wrap">                </span>imgstenc.SetInput(whiteImage);</div><div> <span style="white-space:pre-wrap">                </span>imgstenc.SetStencilConnection(pol2stenc.GetOutputPort());</div>


<div><span style="white-space:pre-wrap">                </span>imgstenc.ReverseStencilOff();</div><div>  <span style="white-space:pre-wrap">                </span>imgstenc.SetBackgroundValue(outval);</div><div>  <span style="white-space:pre-wrap">                </span>imgstenc.Update();</div>


<div> </div><div>  <span style="white-space:pre-wrap">                </span>writer = vtk.vtkMetaImageWriter()</div><div>  <span style="white-space:pre-wrap">                </span>writer.SetFileName(&quot;SphereVolume.mhd&quot;);</div>
<div><span style="white-space:pre-wrap">                </span>writer.SetInputData(imgstenc.GetOutput());</div><div><span style="white-space:pre-wrap">                </span>writer.Write();</div><div><span style="white-space:pre-wrap">                </span>#------------------------------------------------------------------------------------</div>


</div><div><br></div><div><br></div><div>Do you see what can the problem be? Also, I have a plane, vtkImageReslice type, that I want to specifically give as input to the vtkImageStencil (If I&#39;m not mistaken) to get the intersection of my vtkPolyData with that oriented plane. How can I do this the most simple way?</div>


<div><br></div><div><br></div><div>Many thanks for your time,</div><div>Joao</div><div><br></div><div><br></div><div> </div>
</blockquote></div><br></div>