[vtkusers] Cut/Paste region of vtkImageData defined by a contour
adrian.gabriel at 4plus.de
Wed Sep 17 10:56:35 EDT 2014
I currently have the joy of refacturing some code from an old project to
enable new functions.
It is running on vtk 5.6 with some local patches ( saying that, because I
can't use vtkLassooStencilSource ).
*What I understand there is:*
- a vtkImageData (filled/scaled from DICOM source)
- a set of points that is defined as a "contour" drawn by an user ( can be
in any 2d form, most of the time its a rectangle, but you user can free
- a button saying "cut" to extract the pixels from the vtkImageData,
creating a new vtkImageData and leaving a black hole in the origin image.
The old solution uses a bunch of nasty hacks, filling a mask with some magic
numbers... long story short, only the guy who wrote that stuff 5 years ago
knows what he did ( then ).
*What I did/tried*
Found example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/ImageStencil
hard coded an example by using the vtkImageToImageStencil and simply used
two stencils; one with ReverseStencil on and one with off.
Leaving me with the data to update the old plane texture and one to stick to
the newly object.
After that success, I thought to change it to use a
vtkPolyDataToImageStencil and feed it with the contour-points.
vtkSmartPointer<vtkPolyDataToImageStencil> pol2stenc = ...;
pol2stenc->SetInput( contourPoly ); + Update();
vtkSmartPointer<vtkImageStencil> imgstenc ...;
But it simply does not work - maybe I am missing some requirements for the
polydata to feed to the vtkPolyDataToImageStencil?
Or I simply forgot to set an vector for an filter ( image is orientated in
world according to patient orientation in DICOM dataset )
As I am not quite aware of the vtk "language", it could be that I overlooked
an awesomely easy example how to cut into 2d vtkImageData by an area defined
by points, so any idea is welcome.
Any hints, even RTFM ones are welcome
View this message in context: http://vtk.1045678.n5.nabble.com/Cut-Paste-region-of-vtkImageData-defined-by-a-contour-tp5728767.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers