Clip Volume using freehand 2D Curve ROI

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Clip Volume using freehand 2D Curve ROI

Mallikarjun K
Hello All,
I want to clip the volume using the freehand 2D curve drawn on the volume. Can anyone give me some pointers to start with.

Thanks in advance

--
With Kind Regards:
Mallikarjuna K



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Clip Volume using freehand 2D Curve ROI

Sebastian Hilbert
Am Monday 28 March 2016, 15:13:41 schrieb Mallikarjun K:
> Hello All,
> I want to clip the volume using the freehand 2D curve drawn on the volume.
> Can anyone give me some pointers to start with.
>
I would be interested as well :-) I am not aware of any software (except CT
viewer from Philips Intellispace Portal) that allows clipping directly on a
volume rendering.

Sebastian
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Clip Volume using freehand 2D Curve ROI

longbowzhang
In reply to this post by Mallikarjun K
"freehand 2D curve": I think vtkImageTracerWidget will do the job.
Together with vtkPolyDataToImageStencil, it is likely that you will get a stencil, which could be employed to clip the 3D volume.

I am not sure whether this will finally work or not. But give it a try.

Reply | Threaded
Open this post in threaded view
|

Re: Clip Volume using freehand 2D Curve ROI

Simon ESNEAULT-2
Hello,

I don't think vtkImageTracerWidget will work on a Volume Rendering. The doc says "3D widget for tracing on planar props".

I did exactly this, but the ugly way, using Qt to draw on top of the volume rendering. The pipeline is as follow : 

- Capture a screenshot of the current volume rendering ( using GetRenderWindow()->GetRGBACharPixelData( ... ) )
- Load a QPixmap of the screenshot on top the volume rendering's QVTKWidget
- Enable the user to draw using Qt's Scribble example : http://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html
- When the user has finished to draw, convert all points from Qt coordinate system to VTK coordinate system.
- Generate a 3D conic-like mesh using the list of coordinate, the camera position and direction in order to respect the perspective view (not that easy ;) )
- Cap-Clip the mesh with the volume bounding box ( http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/CapClip )
- Generate a mask using vtkPolyDataToImageStencil
- Mask out the part that is below the free hand curve in the volume ( vtkImageMask or an equivalent )
- Remove the QPixmap to restore the volume rendering interaction ...

That is really ugly, and there might be a lot of better way to do this. But the thing is : it just works ;-)

HTH
Simon


2016-03-30 15:54 GMT+02:00 longbowzhang <[hidden email]>:
"freehand 2D curve": I think vtkImageTracerWidget will do the job.
Together with vtkPolyDataToImageStencil, it is likely that you will get a
stencil, which could be employed to clip the 3D volume.

I am not sure whether this will finally work or not. But give it a try.





--
View this message in context: http://vtk.1045678.n5.nabble.com/Clip-Volume-using-freehand-2D-Curve-ROI-tp5737430p5737447.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers



--
------------------------------------------------------------------
Simon Esneault
Rennes, France
------------------------------------------------------------------

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Clip Volume using freehand 2D Curve ROI

longbowzhang
Hello Simon,

Because the author asked "how to clip a volume w/ 2D hand drawn curve" rather than "on a Volume Rendering" context, I proposed to use vtkImageTracerWidget on selected slices. This is probably the easiest way.

Like you said, if to clip a volume in the context of "volume rendering", besides the way you propose, I would propose another alternative.

1 Draw the bounding box (NOT outline) of the volume, but represent this 6-face-bounding-box in terms of Wireframe (via vtkActor->GetProperty()->SetRepresentationToWireframe());
2 Place the vtkImagePlaneWidget on the bounding box (as shown in the attached image);


3 Derive the stencil, which will be used as a mask for clipping in the context of volume rendering.

I think this would work. What's your opinion?
Reply | Threaded
Open this post in threaded view
|

Re: Clip Volume using freehand 2D Curve ROI

Mallikarjun K
Hello Sebastian,longbowzhang and Simon,
I am sorry I couldn't participate in the discussion as I was away for couple of days. Thank you all for your valuable time and pointers.

@Sebastian: Osirix viewer (on Mac) is also having this feature (Scissors) to clip on volume rendering.

@longbowzhang: My mistake, may be I couldn't put the context properly. What I mean is Clip on volume in the context of Volume Rendering only. Based on your pointers 
1.Can I use vtkboxwidget to draw a bounding box on the volume?  I didn't get the pipeline exactly..if you have an example code that would be helpful..

@Simon: I am not using Qt here. I used vtkcontourWidget to draw a curve on the volume as shown below and got the vtkpoints along the curve. Using these points I have created a vtkimpliciteselectionloop and tried to feed this to setclipfunction of VtkClipDataset  which gives unstructured grid output and thought of converting it to structured grid using vtkprobefilter but  with no luck..:)

Inline image 1



On Thu, Mar 31, 2016 at 2:37 AM, longbowzhang <[hidden email]> wrote:
Hello Simon,

Because the author asked "how to clip a volume w/ 2D hand drawn curve"
rather than "on a Volume Rendering" context, I proposed to use
vtkImageTracerWidget on selected slices. This is probably the easiest way.

Like you said, if to clip a volume in the context of "volume rendering",
besides the way you propose, I would propose another alternative.

1 Draw the bounding box (NOT outline) of the volume, but represent this
6-face-bounding-box in terms of Wireframe (via
vtkActor->GetProperty()->SetRepresentationToWireframe());
2 Place the vtkImagePlaneWidget on the bounding box (as shown in the
attached image);
<http://vtk.1045678.n5.nabble.com/file/n5737450/traceOnBB.png>

3 Derive the stencil, which will be used as a mask for clipping in the
context of volume rendering.

I think this would work. What's your opinion?



--
View this message in context: http://vtk.1045678.n5.nabble.com/Clip-Volume-using-freehand-2D-Curve-ROI-tp5737430p5737450.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers



--
With Kind Regards:
Mallikarjuna K,
07795531103/09908238861.


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Clip Volume using freehand 2D Curve ROI

longbowzhang
Mallikarjun K wrote
1.Can I use vtkboxwidget to draw a bounding box on the volume?  I didn't
get the pipeline exactly..if you have an example code that would be
helpful..
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget
Is this what you want?
I still a vtkCubeSource is enough (the following code for setting up the ITW).
       
        vtkSmartPointer<vtkCubeSource> cubeSource =
                vtkSmartPointer<vtkCubeSource>::New();
        cubeSource->SetBounds(imageData->GetBounds());
       
        // skip some codes...
       cubeActor->GetProperty()->SetRepresentationToWireframe();
       
        vtkSmartPointer<vtkImageTracerWidget> tracer =
                vtkSmartPointer<vtkImageTracerWidget>::New();
        tracer->SetInput(imageData);
        tracer->SetInteractor(renderWindowInteractor);
        tracer->SetViewProp(cubeActor);
        tracer->SnapToImageOff();
        tracer->ProjectToPlaneOn();
        tracer->SetProjectionNormalToZAxes();
Reply | Threaded
Open this post in threaded view
|

Re: Clip Volume using freehand 2D Curve ROI

Tharun
This post has NOT been accepted by the mailing list yet.
In reply to this post by Mallikarjun K
Hello,

I have just solved the problem you are asking using vtkImageTracerWidget but with surface data. I suppose you can use the same for volume data. Below is the procedure I have adopted

1) Get the screenshot and hide the existing actors. (If we do not hide, interaction with the widget might be very slow)
2) Visualize the screenshot similar to the scene before taking screenshot.
2) Get the path traced on the screenshot and convert it into screen coordinates.
3) Crop all the points/faces/cells projecting inside the path.

I have tried using vtkImageTracerWidget with a transparent plane visualized above the scene. But the interaction with the widget was slow as my scene consisted of large data.

Hope this helps!