[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vtkusers
Subject:    Re: [vtkusers] VTK contour Widget
From:       Iyas Hamdan <iyas.hamdan () gmail ! com>
Date:       2017-08-25 14:52:41
Message-ID: CANH4YVj=qYL5rRou8ZpL7zyNQEiswohWcNuUV4UDVsVHmwncLA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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@vtk.org] *On Behalf Of *Iyas
> Hamdan
> *Sent:* Friday, August 25, 2017 9:51 AM
> *To:* VTK Users <vtkusers@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
>

[Attachment #5 (text/html)]

<div dir="ltr"><div><div>Thank you Andras for your answer! <br><br></div>Actually \
image contouring is a small part that I need to integrate in the project that i&#39;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). <br><br></div><div>And I tried \
it on 2D images and it&#39;s exatly what i&#39;m looking for, but I can&#39;t get it \
to work in 3D.<br></div><div><br></div><div>I&#39;ll take a look at the source code \
of these applications and see if I could find what I need. <br><br></div><div>Thanks, \
<br><br></div><div>Iyas<br></div></div><div class="gmail_extra"><br><div \
class="gmail_quote">On Fri, Aug 25, 2017 at 4:05 PM, Andras Lasso <span \
dir="ltr">&lt;<a href="mailto:lasso@queensu.ca" \
target="_blank">lasso@queensu.ca</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">





<div link="#0563C1" vlink="#954F72" lang="EN-US">
<div class="m_-7551131441244788584WordSection1">
<p class="MsoNormal">Hello Iyas,<u></u><u></u></p>
<p class="MsoNormal"><u></u>  <u></u></p>
<p class="MsoNormal">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.<u></u><u></u></p> <p class="MsoNormal"><u></u>  <u></u></p>
<p class="MsoNormal">For example:<u></u><u></u></p>
<p class="MsoNormal"><a href="http://www.slicer.org" \
target="_blank">www.slicer.org</a><u></u><u></u></p> <p class="MsoNormal"><a \
href="http://www.itksnap.org" target="_blank">www.itksnap.org</a><u></u><u></u></p> \
<p class="MsoNormal"><a href="http://www.mitk.org" \
target="_blank">www.mitk.org</a><u></u><u></u></p> <p class="MsoNormal"><u></u>  \
<u></u></p> <p class="MsoNormal">Andras<u></u><u></u></p>
<p class="MsoNormal"><a name="m_-7551131441244788584__MailEndCompose"><u></u>  \
<u></u></a></p> <span></span>
<p class="MsoNormal"><b>From:</b> vtkusers [mailto:<a \
href="mailto:vtkusers-bounces@vtk.org" \
target="_blank">vtkusers-bounces@vtk.<wbr>org</a>] <b>On Behalf Of </b>Iyas \
Hamdan<br> <b>Sent:</b> Friday, August 25, 2017 9:51 AM<br>
<b>To:</b> VTK Users &lt;<a href="mailto:vtkusers@vtk.org" \
target="_blank">vtkusers@vtk.org</a>&gt;<br> <b>Subject:</b> [vtkusers] VTK contour \
Widget<u></u><u></u></p><div><div class="h5"> <p class="MsoNormal"><u></u>  \
<u></u></p> <div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hello, <u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I have a problem using the \
vtkcontourwidget in 3D. What I&#39;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. <u></u><u></u></p>
</div>
<p class="MsoNormal">The problem that I&#39;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. \
<u></u><u></u></p> <div>
<p class="MsoNormal"><u></u>  <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Here&#39;s a piece of the code \
i&#39;m using: <br>
<br>
       vtkSmartPointer&lt;<wbr>vtkImageViewer2&gt; ImageViewer = \
vtkSmartPointer&lt;<wbr>vtkImageViewer2&gt;::New();<br>  \
ImageViewer-&gt;SetInputData(<wbr>reader-&gt;GetOutput());<br>  \
ImageViewer-&gt;SetColorLevel(<wbr>127);<br>  \
ImageViewer-&gt;SetColorWindow(<wbr>255);<br> <br>
       vtkSmartPointer&lt;<wbr>vtkRenderWindowInteractor&gt; iren = \
vtkSmartPointer&lt;<wbr>vtkRenderWindowInteractor&gt;::<wbr>New();<br>  \
ImageViewer-&gt;SetupInteractor(<wbr>iren);<br>  ImageViewer-&gt;Render();<br>
       ImageViewer-&gt;GetRenderer()-&gt;<wbr>ResetCamera();<br>
       ImageViewer-&gt;Render();<br>
<br>
       vtkSmartPointer&lt;<wbr>vtkSliderWidget&gt; SliderWidget = \
vtkSmartPointer&lt;<wbr>vtkSliderWidget&gt;::New();<br>  \
SliderWidget-&gt;SetInteractor(<wbr>iren);<br>  \
SliderWidget-&gt;<wbr>SetRepresentation(<wbr>SliderRepres2D);<br>  \
SliderWidget-&gt;<wbr>KeyPressActivationOff();<br>  \
SliderWidget-&gt;<wbr>SetAnimationModeToAnimate();<br>  \
SliderWidget-&gt;SetEnabled(true)<wbr>;<br> <br>
       vtkSmartPointer&lt;<wbr>vtkSliderCallback&gt; SliderCb = \
vtkSmartPointer&lt;<wbr>vtkSliderCallback&gt;::New();<br>  \
                SliderCb-&gt;SetImageViewer(<wbr>ImageViewer);<br>
       SliderWidget-&gt;AddObserver(<wbr>vtkCommand::InteractionEvent, SliderCb);<br>
<br>
       ImageViewer-&gt;SetSlice(static_<wbr>cast&lt;int&gt;(SliderRepres2D-&gt;<wbr>GetValue()));<br>
 <br>
vtkSmartPointer&lt;<wbr>vtkContourWidget&gt; ContourWidget = \
vtkSmartPointer&lt;<wbr>vtkContourWidget&gt;::New();<br>  \
vtkSmartPointer&lt;<wbr>vtkOrientedGlyphContourReprese<wbr>ntation&gt; rep = \
vtkSmartPointer&lt;<wbr>vtkOrientedGlyphContourReprese<wbr>ntation&gt;::New();<br>  \
ContourWidget-&gt;<wbr>SetRepresentation(rep);<br> <br>
       vtkSmartPointer&lt;<wbr>vtkImageActorPointPlacer&gt;   imageActorPointPlacer = \
                vtkSmartPointer&lt;<wbr>vtkImageActorPointPlacer&gt;::<wbr>New();<br>
       imageActorPointPlacer-&gt;<wbr>SetImageActor(ImageViewer-&gt;<wbr>GetImageActor());<br>
  rep-&gt;SetPointPlacer(<wbr>imageActorPointPlacer);<br>
       rep-&gt;GetProperty()-&gt;SetColor(<wbr>0, 1, 0);<br>
<br>
       ContourWidget-&gt;SetInteractor(<wbr>iren);<br>
       ContourWidget-&gt;FollowCursorOn(<wbr>);<br>
       ContourWidget-&gt;SetEnabled(<wbr>true);<br>
       ContourWidget-&gt;<wbr>ProcessEventsOn();<br>
<br>
       iren-&gt;Start();<br>
<br>
<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Any idea what&#39;s causing this \
problem and eventually how to fix it ? <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Any help would be really \
appreciated, <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Thanks in advance, \
<u></u><u></u></p> </div>
<div>
<p class="MsoNormal">Iyas<u></u><u></u></p>
</div>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>



_______________________________________________
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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic