[vtkusers] Combining resliced images and polygons

Scott Johnson Scott.Johnson at neuwave.com
Fri Mar 26 11:05:28 EDT 2010


Thanks Lars and Jothy for the pointer to vtkCutter.

 

I can cut the sphere, but when I add the actor to the ImageViewer2, the cut edge is rendered as black, regardless of what color I set the property of the actor to.  A code sample for the clipping part of the pipeline looks like:

 

# Create the clipping plane for the ROI

plane = vtk.vtkPlane()

 

# Create the cutter to extract contours from the ROI

clippedROI = vtk.vtkCutter()

clippedROI.SetCutFunction(plane)

clippedROI.SetInputConnection(targetSphere.GetOutputPort())

 

clipMapper = vtk.vtkPolyDataMapper()

clipMapper.SetInputConnection(clippedROI.GetOutputPort())

 

# Create the actor to add to vtkImageViewer2

clipActor = vtk.vtkActor()

clipActor.SetMapper(clipMapper)

clipActor.GetProperty().SetColor(1.0, 0.0, 0.0)

clipActor.GetProperty().SetLineWidth(10)

clipActor.GetProperty().SetOpacity(1.0)

 

I set the width of the cut to 10, just to make it easier to see.  Ideally, I'd eventually like to fill the contour with a transparent red color.

 

If I add the clipActor to a Renderer, and turn it on its edge, the uncut edge is indeed red.

 

I am using vtk 5.4 on Windows XP.

 

Thanks again.

 

            -- Scott

 

-----Original Message-----
From: Lars Friedrich Lars [mailto:lars-friedrich at gmx.net] 
Sent: Friday, March 26, 2010 1:16 AM
To: Scott Johnson; vtkusers at vtk.org
Subject: Re: [vtkusers] Combining resliced images and polygons

 

Hello Scott,

 

vtkClipPolyData does not really extract the contour, it clips the poly data with a specified (implicit) function. Clipping a sphere with a plane will produce a hemisphere. Depending on the method of visualization (see below) this could easily make troubles, especially if you set material properties (-> shadows hide parts ...).

 

You should rather use vtkCutter which is really capable of robustly extracting contours emerging from a cut with an implicit function. Depending on the method you're using to visualize the axial/coronal/sagittal views, it might be necessary to modify the plane function a bit to obtain a perfect non-floating visualization. For example the vtkImageViewer2 internally works by generating parallel projections of a 3D scene. Therefore it might be necessary to shift the plane a bit (really a bit - 0.001 or so which is diagnostically irrelevant) towards the camera position. You should also turn off all material props of that contour.

 

HTH,

 

lars

 

 

-------- Original-Nachricht --------

> Datum: Thu, 25 Mar 2010 17:14:38 -0500

> Von: "Scott Johnson" <Scott.Johnson at neuwave.com>

> An: vtkusers at vtk.org

> Betreff: [vtkusers] Combining resliced images and polygons

 

> Hi Folks,

> 

>  

> 

> I'm looking for a pointer.

> 

>  

> 

> I'm trying to display a resliced image, either axial, coronal, or

> sagital and then display a contour representing the same plane cutting

> through a polygonal shape.  In my current example I have created a

> sphere which intersects some of the image slices.  As I scroll through

> the slices I expect to see circles where the slice intersects the

> sphere.

> 

>  

> 

> Right now I have created a SphereSource -> ClipPolyData ->

> PolyDataMapper -> Actor.  The ClipPolyData has a plane as the clip

> function.

> 

>  

> 

> For the images I have ImageReslice -> ImageMapToWindowLevelColors ->

> ImageActor

> 

>  

> 

> Both of these actors are connected to a Renderer and added to a

> RenderWindow.

> 

>  

> 

> What I get is a slice and half of a sphere floating over it.  I can't

> get the circle to be reflected on the image.  I've also tried to use an

> ImageViewer2 for the display to no avail.

> 

>  

> 

> My original plan was to sync the plane definitions in the ImageReslice

> and the clipping plane, but I can't get past this point.

> 

>  

> 

> This seems much more difficult than it needs to be.  Is there a simpler

> way?

> 

>  

> 

> Thanks

> 

>  

> 

>                                 -- Scott

> 

>  

> 

 

-- 

GMX DSL: Internet, Telefon und Entertainment für nur 19,99 EUR/mtl.!

http://portal.gmx.net/de/go/dsl02

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100326/e1c10627/attachment.htm>


More information about the vtkusers mailing list