[vtkusers] VTK contour Widget

Iyas Hamdan iyas.hamdan at gmail.com
Fri Aug 25 10:52:41 EDT 2017


Thank you Andras for your answer!

Actually image contouring is a small part that I need to integrate in the
project that i'm working on.  I thought I could use vtk contour widget to
do that (since i dont need all the features in slicer or itk snap for
example).

And I tried it on 2D images and it's exatly what i'm looking for, but I
can't get it to work in 3D.

I'll take a look at the source code of these applications and see if I
could find what I need.

Thanks,

Iyas

On Fri, Aug 25, 2017 at 4:05 PM, Andras Lasso <lasso at queensu.ca> wrote:

> Hello Iyas,
>
>
>
> There are many VTK-based applications that allow contouring on image
> slices. I would recommend to extend/modify these applications to suit your
> needs, instead of reimplementing everything from scratch. If you just want
> to implement this as a learning experience, then you can check out the
> source code of these existing applications, you can learn a lot about how
> to implement this and many other features.
>
>
>
> For example:
>
> www.slicer.org
>
> www.itksnap.org
>
> www.mitk.org
>
>
>
> Andras
>
>
>
> *From:* vtkusers [mailto:vtkusers-bounces at vtk.org] *On Behalf Of *Iyas
> Hamdan
> *Sent:* Friday, August 25, 2017 9:51 AM
> *To:* VTK Users <vtkusers at vtk.org>
> *Subject:* [vtkusers] VTK contour Widget
>
>
>
> Hello,
>
> I have a problem using the vtkcontourwidget in 3D. What I'm trying to do
> is to draw contours on my 3D image, where a different contour can be drawn
> on each slice of the image.
>
> The problem that I'm getting is that when I draw a contour on one of the
> slices, the same contour appears on all the other slices as well.
>
>
>
> Here's a piece of the code i'm using:
>
>     vtkSmartPointer<vtkImageViewer2> ImageViewer = vtkSmartPointer<
> vtkImageViewer2>::New();
>     ImageViewer->SetInputData(reader->GetOutput());
>     ImageViewer->SetColorLevel(127);
>     ImageViewer->SetColorWindow(255);
>
>     vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<
> vtkRenderWindowInteractor>::New();
>     ImageViewer->SetupInteractor(iren);
>     ImageViewer->Render();
>     ImageViewer->GetRenderer()->ResetCamera();
>     ImageViewer->Render();
>
>     vtkSmartPointer<vtkSliderWidget> SliderWidget = vtkSmartPointer<
> vtkSliderWidget>::New();
>     SliderWidget->SetInteractor(iren);
>     SliderWidget->SetRepresentation(SliderRepres2D);
>     SliderWidget->KeyPressActivationOff();
>     SliderWidget->SetAnimationModeToAnimate();
>     SliderWidget->SetEnabled(true);
>
>     vtkSmartPointer<vtkSliderCallback> SliderCb = vtkSmartPointer<
> vtkSliderCallback>::New();
>     SliderCb->SetImageViewer(ImageViewer);
>     SliderWidget->AddObserver(vtkCommand::InteractionEvent, SliderCb);
>
>     ImageViewer->SetSlice(static_cast<int>(SliderRepres2D->GetValue()));
>
> vtkSmartPointer<vtkContourWidget> ContourWidget = vtkSmartPointer<
> vtkContourWidget>::New();
>     vtkSmartPointer<vtkOrientedGlyphContourRepresentation> rep =
> vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
>     ContourWidget->SetRepresentation(rep);
>
>     vtkSmartPointer<vtkImageActorPointPlacer>  imageActorPointPlacer =
> vtkSmartPointer<vtkImageActorPointPlacer>::New();
>     imageActorPointPlacer->SetImageActor(ImageViewer->GetImageActor());
>     rep->SetPointPlacer(imageActorPointPlacer);
>     rep->GetProperty()->SetColor(0, 1, 0);
>
>     ContourWidget->SetInteractor(iren);
>     ContourWidget->FollowCursorOn();
>     ContourWidget->SetEnabled(true);
>     ContourWidget->ProcessEventsOn();
>
>     iren->Start();
>
> Any idea what's causing this problem and eventually how to fix it ?
>
> Any help would be really appreciated,
>
> Thanks in advance,
>
> Iyas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170825/3c5216f1/attachment.html>


More information about the vtkusers mailing list