[vtkusers] How to crop a rectangular volume of interest from an image when your roi is defined as polydata?

L.J. van Ruijven L.J.vanRuijven at amc.uva.nl
Mon Apr 6 02:41:59 EDT 2009


Hi Sachin/all,

I am also looking for methods to extract a VOI from a vtkImageData structure for the case that the VOI is defined as a vtkPolyData structure. I also noticed that current method (vtkextractvoi and vtkoutlinefilter) gives a VOI, which is not identical to the original vtkPolyData structure. Since we often define the VOI with an accuracy of one point, the difference very annoying. So I am also looking for an alternative. 

Until now I have not found a way to construct an alternative method with the existing objects in VTK. But maybe I missed something, so does anybody know a method to extract a VOI without distorting the angles using existing objects?

If not, suggestions for a new algorithm are also welcome.

regards,
Leo.




>  Message: 11
>  Date: Sun, 15 Feb 2009 10:55:34 -0500
>  From: Sachin Jambawalikar <sachinjam at gmail.com>
>  Subject: [vtkusers] How to crop a rectangular volume of interest from
>  	an	image when your roi is defined as polydata?
>  To: vtkusers at vtk.org
>  Message-ID:
>  	<6735efef0902150755r335b2b03wd8d6c739bdac18b6 at mail.gmail.com>
>  Content-Type: text/plain; charset="iso-8859-1"
>  
>  Hi all,
>  
>  I  generated a  vtkcube source and then used vtktransform to scale
>  translate and rotate the cube so that it become a rectangular voi .
>  I use the  vtkTransformPolydataFilter  to apply the transform to the
>  cube data. This polydata is then mapped into a vtkactor and added
>  along with exisitng volume data to vtksliceviewer2.
>  This works well and I see a rectangular voi shifted , scaled and
>  translated from center of my volume data.
>  
>  However what I'm trying to develop is a vtk slice viewer which will
>  show   the region of intersection of the volume of interest and the
>  image data in each slice (like an alpha-blended overlay rather than a
>  polygon actor which occlude the slice). I need to generate a subvolume
>  of the Original data from this transformed rectangular voi.  I have
>  seen people using vtkextractvoi by first using vtkoutlinefilter to
>  generate a bounding box. However bounding box limits are not the same
>  as the polydata (because when I display an actor from vtkoutlinefilter
>  it is bigger and doesnot show angulation as shown by the trinangulated
>  polydata actor)
>  
>  What I need to do is extract  a subvolume form Image data
>  corresponding to the  rectangular voi. Create a composite volume (or
>  overlay the  voi volume )and then hopefully be able to show the voi
>  volume
>  transparent overlayed on Image data so as I move through the slices
>  Ican see the structure of the original data  inside the voi. I have
>  attached the code  as to how i generate my rectangular voi and it
>  seems to work.
>  
>  
>  Thanks for all your help
>  
>  Regards
>  --Sachin
>  
>  
>  
>  
>  
>  vtkImagedata=reader.GetOutput()
>  
>  (xMin, xMax, yMin, yMax, zMin, zMax) = reader.GetOutput().GetWholeExtent()
>  (sx, sy, sz) = reader.GetOutput().GetSpacing()
>  print sz
>  (ox, oy, oz) = reader.GetOutput().GetOrigin()
>  #print (x0, y0, z0)
>  center = [ox + sx * 0.5 * (xMin + xMax),
>            oy + sy * 0.5 * (yMin + yMax),
>            oz + sz * 0.5 * (zMin + zMax)]
>  
>  
>  
>  # An outline is shown for context.
>  outline = vtk.vtkOutlineFilter()
>  outline.SetInputConnection(reader.GetOutputPort())
>  
>  outlineMapper = vtk.vtkPolyDataMapper()
>  outlineMapper.SetInputConnection(outline.GetOutputPort())
>  
>  outlineActor = vtk.vtkActor()
>  outlineActor.SetMapper(outlineMapper)
>  
>  ####roi
>  cube = vtk.vtkCubeSource()
>  cube.SetXLength(1);
>  cube.SetYLength(1);
>  cube.SetZLength(1);
>  vtkmath=vtk.vtkMath()
>  
>  
>  transP1 = vtk.vtkTransform()
>  transP1.Identity()
>  transP1.PostMultiply()
>  
>  transP1.Scale(10, 27.5,9.942770958)
>  transP1.RotateX(22.90897369)
>  transP1.RotateY(0.1529316902)
>  
>  #transP1.RotateX(0)
>  transP1.RotateZ(0.7547413111)
>  
>  transP1.Translate(center[0]-22, center[1]-17, center[2]+11)
>  
>  
>  tpd1 = vtk.vtkTransformPolyDataFilter()
>  tpd1.SetInputConnection(cube.GetOutputPort())
>  tpd1.SetTransform(transP1)
>  
>  #triangulate points
>  triangle=vtk.vtkTriangleFilter()
>  triangle.SetInputConnection(tpd1.GetOutputPort())
>  
>  #outTpd1 = vtk.vtkOutlineFilter()
>  #outTpd1.SetInputConnection(triangle.GetOutputPort())
>  
>  #mapper
>  mapTpd1 = vtk.vtkPolyDataMapper()
>  #mapTpd1.SetInputConnection(outTpd1.GetOutputPort())
>  mapTpd1.SetInputConnection(triangle.GetOutputPort())
>  
>  #Actor
>  roiActor = vtk.vtkActor()
>  roiActor.SetMapper(mapTpd1)
>  roiActor.GetProperty().SetColor(1, 0, 0)
>  -------------- next part --------------
>  A non-text attachment was scrubbed...
>  Name: vtkimage.jpg
>  Type: image/jpeg
>  Size: 84008 bytes
>  Desc: not available
>  URL: <
>  

-------------- next part --------------
A non-text attachment was scrubbed...
Name: L.J.vanRuijven.vcf
Type: text/x-vcard
Size: 261 bytes
Desc: Card for "L.J. van Ruijven" <L.J.vanRuijven at amc.uva.nl>
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090406/e28ac236/attachment.vcf>


More information about the vtkusers mailing list