&gt;this uses a standard vtk data set.<br>A standard vtk dataset, absolutely brilliant (I was wondering how to demonstrate this)! <br><br> I ran the code with and without the commented section.  SetExtractionModeToLargestRegion() eliminates some of the data (size(ar) shrinks from 618 to 597). However, I&#39;m not sure what it eliminates. When I plot a slice of ar (AR[2]&gt;0.899999) I get the same plot.  A link to a screen shot of python running in two seperate process (uncommented is the upper) is available at <a href="http://www.et.byu.edu/~pah32/VTK/ScreenCapture.PNG">http://www.et.byu.edu/~pah32/VTK/ScreenCapture.PNG</a><br>
<br>The modified code is below<br><br>=========================================<br>cd C:\Users\Peter\Desktop\VTKTEMP<br><br>import vtk<br>import vtk.util.numpy_support as VN<br>from pylab import *<br><br>reader = vtk.vtkRectilinearGridReader()<br>
reader.SetFileName(&#39;.\RectGrid2.vtk&#39;)<br><br>skinExtractor = vtk.vtkContourFilter()<br>skinExtractor.SetInputConnection(reader.GetOutputPort())<br>skinExtractor.SetValue(0, 5.2)<br><br>skinConnect=vtk.vtkPolyDataConnectivityFilter()<br>
skinConnect.SetInputConnection(skinExtractor.GetOutputPort())<br><br># All Regions:<br>skinConnect.SetExtractionModeToAllRegions()<br>skinConnect.SetColorRegions(1)<br><br># Largest Region:<br>skinConnect.SetExtractionModeToLargestRegion()<br>
<br>skinNormals = vtk.vtkPolyDataNormals()<br>skinNormals.SetInputConnection(skinConnect.GetOutputPort())<br>skinNormals.SetFeatureAngle(60.0)<br><br>skinMapper = vtk.vtkPolyDataMapper()<br>skinMapper.SetInputConnection(skinNormals.GetOutputPort())<br>
skinMapper.ScalarVisibilityOn()<br>skinMapper.SetColorModeToMapScalars()<br>skinMapper.SelectColorArray(&#39;scalars&#39;)<br><br>skinActor = vtk.vtkActor()<br>skinActor.SetMapper(skinMapper)<br><br>skinu = skinNormals.GetOutput()<br>
# Force the pipeline to execute<br>skinu.Update()<br><br>ar = VN.vtk_to_numpy(skinu.GetPoints().GetData())<br>#print ar<br>temp=[]<br><br>for item in ar:<br>    if item[2]&gt;0.899999:<br>        temp+=[item]<br>       <br>
       <br>temp=array(temp)<br>x1=temp[:,0]<br>y1=temp[:,1]<br><br>scatter(x1,y1)<br>show()<br><br>ren = vtk.vtkRenderer()<br>ren.AddActor(skinActor)<br>renWin = vtk.vtkRenderWindow()<br>renWin.AddRenderer(ren)<br>iren = vtk.vtkRenderWindowInteractor()<br>
iren.SetRenderWindow(renWin)<br><br>ren.ResetCamera()<br>renWin.Render()<br>iren.Initialize()<br>iren.Start()<br><br>=========================================<br><br>Thanks for your help.<br><br><br><div class="gmail_quote">
On Mon, May 18, 2009 at 7:48 AM, Eric E. Monson <span dir="ltr">&lt;<a href="mailto:emonson@cs.duke.edu">emonson@cs.duke.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey Peter,<br>
<br>
I think the filter is working correctly. Try this modification of your earlier script. (Again, this uses a standard VTK data set.)<br>
<br>
By default I&#39;ve changed the option on the connectivity filter to grab all regions, but color them by their region number. You should see two sort of parabolic-shaped regions, one red and one blue. If you comment out the &quot;all regions&quot; stuff and use the &quot;largest region&quot;, you should just see the large region in the render window. You can also see that there are extra coordinate points printed out for the &quot;all regions&quot; case, so I think the data is getting to the numpy array correctly.<br>

<br>
===============<br>
import vtk<br>
import vtk.util.numpy_support as VN<br>
<br>
reader = vtk.vtkRectilinearGridReader()<br>
reader.SetFileName(&#39;/Users/emonson/Programming/VTK_cvs/VTKData/Data/RectGrid2.vtk&#39;)<br>
<br>
skinExtractor = vtk.vtkContourFilter()<br>
skinExtractor.SetInputConnection(reader.GetOutputPort())<br>
skinExtractor.SetValue(0, 5.2)<br>
<br>
skinConnect=vtk.vtkPolyDataConnectivityFilter()<br>
skinConnect.SetInputConnection(skinExtractor.GetOutputPort())<br>
<br>
# All Regions:<br>
skinConnect.SetExtractionModeToAllRegions()<br>
skinConnect.SetColorRegions(1)<br>
<br>
# Largest Region:<br>
# skinConnect.SetExtractionModeToLargestRegion()<br>
<br>
skinNormals = vtk.vtkPolyDataNormals()<br>
skinNormals.SetInputConnection(skinConnect.GetOutputPort())<br>
skinNormals.SetFeatureAngle(60.0)<br>
<br>
skinMapper = vtk.vtkPolyDataMapper()<br>
skinMapper.SetInputConnection(skinNormals.GetOutputPort())<br>
skinMapper.ScalarVisibilityOn()<br>
skinMapper.SetColorModeToMapScalars()<br>
skinMapper.SelectColorArray(&#39;scalars&#39;)<br>
<br>
skinActor = vtk.vtkActor()<br>
skinActor.SetMapper(skinMapper)<br>
<br>
skinu = skinNormals.GetOutput()<br>
# Force the pipeline to execute<br>
skinu.Update()<br>
<br>
ar = VN.vtk_to_numpy(skinu.GetPoints().GetData())<br>
print ar<br>
<br>
ren = vtk.vtkRenderer()<br>
ren.AddActor(skinActor)<br>
renWin = vtk.vtkRenderWindow()<br>
renWin.AddRenderer(ren)<br>
iren = vtk.vtkRenderWindowInteractor()<br>
iren.SetRenderWindow(renWin)<br>
<br>
ren.ResetCamera()<br>
renWin.Render()<br>
iren.Initialize()<br>
iren.Start()<br>
<br>
===============<br>
<br>
Hope this helps clear it up,<br>
-Eric<br>
<br>
------------------------------------------------------<br>
Eric E Monson<br>
Duke Visualization Technology Group<div><div></div><div class="h5"><br>
<br>
<br>
On May 14, 2009, at 10:52 AM, Peter Halverson wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
I&#39;m having some difficulty with vtkPolyDataConnectivityFilter().  VTK is able to visualize it but I can&#39;t get the data out of it.  I&#39;ve written a program that works as follows<br>
<br>
1. Uses vtkDICOMImageReader() to read in a CT image and pass that to<br>
2. vtkContourfilter() to reduce that image and pass that to<br>
3. vtkPolyDataConnectivityFilter() to get the largest connected region and pass that to<br>
4. vtkPolyDataNormals() which passes it to<br>
5. vtkPolyDataMapper() and then to<br>
6. vtkActor() which is able to render only the largest connected region (the skin in this case)<br>
<br>
When I pass the data to python using vtk_ar=vtk_to_numpy(skinactor.GetMapper().GetInput().GetPoints().GetData()) I get the output from step 2 which includes the disconnected regions.  I&#39;ve searched the vtk mail archives and the books but can&#39;t find out how to get the data after the ConnectivityFilter is called. I&#39;m new to vtk, any help would be appreciated.<br>

<br>
Peter<br></div></div>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote>
<br>
</blockquote></div><br>