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

List:       vtkusers
Subject:    Re: [vtkusers] Extract slices from a vtkMetaImageReader with
From:       "mathilde.merle" <mathilde.merle () laposte ! net>
Date:       2011-06-30 15:11:51
Message-ID: 2246891.183551.1309446676999.JavaMail.www () wwinf8222
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thank you for "SetSlice", it is really usefull.

When I pick a pixel on the vtkImageViewer2, I display the good location in the image \
and in space.

However It still remains 2 problems :

- The image does not change at the beginning if I change the slice_nb.

-   When I move the mouse on the image, I want to change the slice :

case vtkCommand::MouseMoveEvent:
                               style->OnMouseMove();
                            
                               // Change slice
                               int slice_nb = Viewer->GetSlice();
                               Viewer->SetSlice(slice_nb++);

                               cout<<"MOUSE MOVE EVENT :"<Render();
                               style->OnMouseMove();
                               break;          

And slice_nb does not change even if I enter several times in this code.

(excuse my english...)

Mathilde

> Message du 30/06/11 16:19
> De : "Jothy"
> A : "mathilde.merle"
> Copie à : "vtkusers vtk org"
> Objet : Re: [vtkusers] Extract slices from a vtkMetaImageReader with vtkExtractVOI
> 
> If you use vtkImageViewer2, you shouls use setSlice and setorientationTo methods to \
> set the desired orientation adn the slice no after setting the \
> setInput/setinputConnection. 
> have a look at this link
> 
> http://devsample.org/index.php?option=com_content&task=view&id=47&Itemid=27
> 
> Jothy
> 
> On Thu, Jun 30, 2011 at 4:01 PM, mathilde.merle  wrote:
> 
> I use vtkImageViewer2 :
> 
> // VIEWER TOOL : Pick a Pixel
> // Picker to pick pixels
> vtkSmartPointer propPicker = vtkSmartPointer::New();
> propPicker->PickFromListOn();
> 
> // Give the picker a prop to pick
> vtkSmartPointer imageViewer = vtkSmartPointer::New();
> vtkImageActor* imageActor = imageViewer->GetImageActor();
> propPicker->AddPickList(imageActor);
> 
> // disable interpolation, so we can see each pixel
> imageActor->InterpolateOff();
> 
> > Message du 30/06/11 15:54
> > De : "Jothy"
> > A : "mathilde.merle"
> > Copie à : "vtkusers vtk org"
> > Objet : Re: [vtkusers] Extract slices from a vtkMetaImageReader with \
> > vtkExtractVOI 
> > 
Which image viewer are you using here?
> > 
> > Jothy
> > 
> > 
On Thu, Jun 30, 2011 at 3:41 PM, mathilde.merle  wrote:
> > 
> > 

> > Hello,
> > 
> > I'm trying to extract slices from a vtkImagedata sequence and then display it.
> > 
> > I tryed with vtkImageReslice and then vtkextractVOI, but it don't work. The image \
> > displayed is always the same even if I change 'slice_nb'. 
> > How can I do ?
> > 
> > My code :
> > 
> > int* dims = reader->GetOutput()->GetDimensions();
> > 
> > // extract slice
> > 
> > int slice_nb = 0;
> > 
> > vtkSmartPointer extractVOI = vtkSmartPointer::New();
> > extractVOI->SetInputConnection(reader->GetOutputPort());
> > extractVOI->SetVOI(0,dims[0],0,dims[1], slice_nb, slice_nb); //extract first \
> > image extractVOI->Update();
> > 
> > vtkImageData* extracted = extractVOI->GetOutput();
> > 
> > int* dims2 = extracted->GetDimensions();
> > cout << "DimensionsExtracted = ";
> > for (int i=0; i<(int)(sizeof(dims2)/sizeof(int)+1); i++) {
> > cout << dims2[i]<<", ";
> > }
> > cout << endl; // Get a good image dimension
> > 
> > // Visualize
> > vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New();
> > imageViewer->SetInputConnection(extractVOI->GetOutputPort() );
> > imageViewer->SetupInteractor( renderWindowInteractor );
> > imageViewer->SetSize( 600, 600 );
> > 
> > vtkRenderer* renderer = imageViewer->GetRenderer();
> > renderer->ResetCamera();
> > renderer->GradientBackgroundOn();
> > renderer->SetBackground(0,0,0);
> > renderer->SetBackground2(1,1,1);
> > 
> > // Annotate the image with window/level and mouse over pixel information
> > vtkSmartPointer cornerAnnotation = vtkSmartPointer::New();
> > cornerAnnotation->SetLinearFontScaleFactor( 2 );
> > cornerAnnotation->SetNonlinearFontScaleFactor( 1 );
> > cornerAnnotation->SetMaximumFontSize( 20 );
> > cornerAnnotation->SetText( 0, "Off Image" );
> > cornerAnnotation->SetText( 3, "\n" );
> > cornerAnnotation->GetTextProperty()->SetColor( 1,0,0);
> > 
> > imageViewer->GetRenderer()->AddViewProp( cornerAnnotation );
> > 
> > // Callback listens to MouseMoveEvents invoked by the interactor's style
> > vtkSmartPointer callback = vtkSmartPointer::New();
> > callback->SetViewer( imageViewer );
> > callback->SetAnnotation( cornerAnnotation );
> > callback->SetPicker( propPicker );
> > callback->SetOrigin( orgn[0], orgn[1], orgn[2]); // add the origin of the \
> > sequence into the class 
> > // Events recognized
> > vtkInteractorStyleImage* imageStyle = imageViewer->GetInteractorStyle();
> > imageStyle->AddObserver( vtkCommand::MouseMoveEvent, callback );
> > imageStyle->AddObserver( vtkCommand::LeftButtonReleaseEvent, callback );
> > 
> > renderWindowInteractor->Initialize();
> > renderWindowInteractor->Start();      
> > 
> > 
> > Thanks
> > 
> > Mathilde
> > 
> > 
> > _______________________________________________
> > 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 
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> > 
> > > 

> > > 

> 
> 
> 

Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
Je crée ma boîte mail www.laposte.net


[Attachment #5 (text/html)]

Thank you for &quot;SetSlice&quot;, it is really usefull.<br /><br />When I pick a \
pixel on the vtkImageViewer2, I display the good location in the image and in space. \
<br /><br />However It still remains 2 problems :<br /><br />- The image does not \
change at the beginning if I change the slice_nb.<br /><br />-&nbsp; When I move the \
mouse on the image, I want to change the slice :<br /><br /><em>case \
vtkCommand::MouseMoveEvent:<br \
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
style-&gt;OnMouseMove();<br \
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
// Change slice<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
int slice_nb = Viewer-&gt;GetSlice();<br \
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
Viewer-&gt;SetSlice(slice_nb++);<br /><br \
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
cout&lt;&lt;&quot;MOUSE MOVE EVENT :&quot;&lt;&lt;slice_nb++&lt;&lt;endl;<br \
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
interactor-&gt;Render();<br \
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
style-&gt;OnMouseMove();<br \
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
break;&nbsp;&nbsp;&nbsp;</em>&nbsp;&nbsp; <br /><br />And slice_nb does not change \
even if I enter several times in this code.<br /><br />(excuse my english...)<br \
/><br />Mathilde<br /><br /><blockquote style="padding-left: 5px; margin-left: 5px; \
border-left: 2px solid #ff0000">&gt; Message du 30/06/11 16:19<br />&gt; De : \
&quot;Jothy&quot; <br />&gt; A : &quot;mathilde.merle&quot; <br />&gt; Copie &agrave; \
: &quot;vtkusers vtk org&quot; <br />&gt; Objet : Re: [vtkusers] Extract slices from \
a vtkMetaImageReader with vtkExtractVOI<br />&gt;<br />&gt; <p \
style="margin:0;padding:0;" dir="ltr">If you use vtkImageViewer2, you shouls use \
setSlice and setorientationTo methods to set the desired orientation adn the slice no \
after setting the setInput/setinputConnection.<br />&gt; <br />&gt; have a look at \
this link<br />&gt;  <br />&gt; <a \
href="http://devsample.org/index.php?option=com_content&amp;task=view&amp;id=47&amp;It \
emid=27">http://devsample.org/index.php?option=com_content&amp;task=view&amp;id=47&amp;Itemid=27</a><br \
/>&gt; <br />&gt; Jothy<br />&gt; <br />&gt; <p style="margin:0;padding:0;" \
class="gmail_quote"> On Thu, Jun 30, 2011 at 4:01 PM, mathilde.merle <span>&lt;<a \
href="mailto:mathilde.merle@laposte.net">mathilde.merle@laposte.net</a>&gt;</span> \
wrote:<br />&gt; <blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid \
#cccccc; padding-left: 1ex"> <br />&gt; I use <em>vtkImageViewer2 :</em><br />&gt; \
<em><br />&gt; &nbsp;&nbsp;&nbsp; // VIEWER TOOL : Pick a Pixel<br />&gt; \
&nbsp;&nbsp;&nbsp; // Picker to pick pixels<br />&gt; &nbsp;&nbsp;&nbsp; \
vtkSmartPointer propPicker = vtkSmartPointer::New();<br />&gt; &nbsp;&nbsp;&nbsp; \
propPicker-&gt;PickFromListOn();<br />&gt;  &nbsp;&nbsp;&nbsp; <br />&gt; \
&nbsp;&nbsp;&nbsp; // Give the picker a prop to pick<br />&gt; &nbsp;&nbsp;&nbsp; \
vtkSmartPointer imageViewer = vtkSmartPointer::New();<br />&gt; &nbsp;&nbsp;&nbsp; \
vtkImageActor* imageActor = imageViewer-&gt;GetImageActor();<br />&gt;  \
&nbsp;&nbsp;&nbsp; propPicker-&gt;AddPickList(imageActor);<br />&gt; \
&nbsp;&nbsp;&nbsp; <br />&gt; &nbsp;&nbsp;&nbsp; // disable interpolation, so we can \
see each pixel<br />&gt; &nbsp;&nbsp;&nbsp; imageActor-&gt;InterpolateOff();</em><br \
/>&gt; <br />&gt; <blockquote style="padding-left: 5px; margin-left: 5px; \
border-left: 2px solid #ff0000"> &gt; Message du 30/06/11 15:54<br />&gt; &gt; De : \
&quot;Jothy&quot; <br />&gt; &gt; A : &quot;mathilde.merle&quot; <br />&gt; &gt; \
Copie &agrave; : &quot;vtkusers vtk org&quot; <br />&gt; &gt; Objet : Re: [vtkusers] \
Extract slices from a vtkMetaImageReader with vtkExtractVOI<br />&gt;  &gt;<br />&gt; \
&gt; <p style="margin: 0pt; padding: 0pt" dir="ltr">&nbsp;</p><p \
style="margin:0;padding:0;" class="im">Which image viewer are you using here?<br \
/>&gt; &gt; <br />&gt; &gt; Jothy<br />&gt; &gt; <br />&gt; &gt; </p><p \
style="margin: 0pt; padding: 0pt" class="gmail_quote">&nbsp;</p><p \
style="margin:0;padding:0;" class="im"> On Thu, Jun 30, 2011 at 3:41 PM, \
mathilde.merle <span>&lt;<a href="mailto:mathilde.merle@laposte.net" \
target="_blank">mathilde.merle@laposte.net</a>&gt;</span> wrote:<br />&gt; &gt;  \
</p><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid #cccccc; \
padding-left: 1ex"> <p style="margin:0;padding:0;" class="im"><p style="margin: 0pt; \
padding: 0pt" align="left"><br />&gt; &gt; </p><br />&gt; &gt; Hello,<br />&gt; &gt; \
<br />&gt; &gt; I'm trying to extract slices from a vtkImagedata sequence and then \
display it. <br />&gt; &gt;  <br />&gt; &gt; I tryed with vtkImageReslice and then \
vtkextractVOI, but it don't work. The image displayed is always the same even if I \
change 'slice_nb'. <br />&gt;  &gt; <br />&gt; &gt; How can I do ?<br />&gt; &gt; <br \
/>&gt; &gt; My code :<br />&gt; &gt; </p><em><br />&gt; <p \
style="margin:0;padding:0;" class="im">&gt; int* dims = \
reader-&gt;GetOutput()-&gt;GetDimensions();<br />&gt; &gt;  <br />&gt; &gt; // \
extract slice<br />&gt; &gt; <br />&gt; &gt; <strong>int slice_nb = 0;</strong><br \
/>&gt;  &gt; <br />&gt; </p>&gt; <strong>vtkSmartPointer extractVOI = \
vtkSmartPointer::New();<p style="margin:0;padding:0;" class="im"><br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; extractVOI-&gt;SetInputConnection(reader-&gt;GetOutputPort());<br \
/>&gt; &gt;  &nbsp;&nbsp;&nbsp; extractVOI-&gt;SetVOI(0,dims[0],0,dims[1], slice_nb, \
slice_nb); //extract first image<br />&gt;  &gt; &nbsp;&nbsp;&nbsp; \
extractVOI-&gt;Update();</p></strong><p style="margin:0;padding:0;" class="im"><br \
/>&gt; &gt; &nbsp;&nbsp;&nbsp; <br />&gt; &gt; &nbsp;&nbsp;&nbsp; vtkImageData* \
extracted = extractVOI-&gt;GetOutput();<br />&gt; &gt; <br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; int* dims2 = extracted-&gt;GetDimensions();<br />&gt; &gt;  \
&nbsp;&nbsp;&nbsp; cout &lt;&lt; &quot;DimensionsExtracted = &quot;;<br />&gt;  &gt; \
&nbsp;&nbsp;&nbsp; for (int i=0; i&lt;(int)(sizeof(dims2)/sizeof(int)+1); i++) { <br \
/>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; \
dims2[i]&lt;&lt;&quot;, &quot;;<br />&gt; &gt; &nbsp;&nbsp;&nbsp; }<br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; cout &lt;&lt; endl; // Get a good image dimension<br />&gt; &gt;  \
&nbsp;&nbsp;&nbsp; <br />&gt;  &gt; // Visualize<br />&gt; </p>&gt; \
&nbsp;&nbsp;&nbsp; vtkSmartPointer renderWindowInteractor = vtkSmartPointer::New();<p \
style="margin:0;padding:0;" class="im"><br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
imageViewer-&gt;SetInputConnection(<strong>extractVOI-&gt;GetOutputPort() \
</strong>);<br />&gt; &gt;  &nbsp;&nbsp;&nbsp; imageViewer-&gt;SetupInteractor( \
renderWindowInteractor );<br />&gt;  &gt; &nbsp;&nbsp;&nbsp; imageViewer-&gt;SetSize( \
600, 600 );<br />&gt; &gt; &nbsp;&nbsp;&nbsp; <br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
vtkRenderer* renderer = imageViewer-&gt;GetRenderer();<br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; renderer-&gt;ResetCamera();<br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
renderer-&gt;GradientBackgroundOn();<br />&gt; &gt;  &nbsp;&nbsp;&nbsp; \
renderer-&gt;SetBackground(0,0,0);<br />&gt;  &gt; &nbsp;&nbsp;&nbsp; \
renderer-&gt;SetBackground2(1,1,1);<br />&gt; &gt; &nbsp;&nbsp;&nbsp; <br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; // Annotate the image with window/level and mouse over pixel \
information<br />&gt; </p>&gt; &nbsp;&nbsp;&nbsp; vtkSmartPointer cornerAnnotation = \
vtkSmartPointer::New();<p style="margin:0;padding:0;" class="im"> <br />&gt; &gt;  \
&nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetLinearFontScaleFactor( 2 );<br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetNonlinearFontScaleFactor( 1 );<br />&gt; \
&gt; &nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetMaximumFontSize( 20 );<br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetText( 0, &quot;Off Image&quot; );<br \
/>&gt;  </p>&gt;  &nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetText( 3, &quot;\n&quot; \
);<p style="margin:0;padding:0;" class="im"><br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
cornerAnnotation-&gt;GetTextProperty()-&gt;SetColor( 1,0,0);<br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; <br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
imageViewer-&gt;GetRenderer()-&gt;AddViewProp( cornerAnnotation );<br />&gt;  &gt;  \
&nbsp;&nbsp;&nbsp; <br />&gt; &gt; &nbsp;&nbsp;&nbsp; // Callback listens to \
MouseMoveEvents invoked by the interactor's style<br />&gt; </p>&gt; \
&nbsp;&nbsp;&nbsp; vtkSmartPointer callback = vtkSmartPointer::New();<p \
style="margin:0;padding:0;" class="im"><br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
callback-&gt;SetViewer( imageViewer );<br />&gt;  &gt;  &nbsp;&nbsp;&nbsp; \
callback-&gt;SetAnnotation( cornerAnnotation );<br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
callback-&gt;SetPicker( propPicker );<br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
callback-&gt;SetOrigin( orgn[0], orgn[1], orgn[2]); // add the origin of the sequence \
into the class<br />&gt;  &gt; <br />&gt; &gt; &nbsp;// Events recognized <br />&gt; \
&gt;  &nbsp;&nbsp;&nbsp; vtkInteractorStyleImage* imageStyle = \
imageViewer-&gt;GetInteractorStyle();<br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
imageStyle-&gt;AddObserver( vtkCommand::MouseMoveEvent, callback );<br />&gt; &gt; \
&nbsp;&nbsp;&nbsp; imageStyle-&gt;AddObserver( vtkCommand::LeftButtonReleaseEvent, \
callback );<br />&gt;  &gt;  <br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
renderWindowInteractor-&gt;Initialize();<br />&gt; &gt; &nbsp;&nbsp;&nbsp; \
renderWindowInteractor-&gt;Start();&nbsp;&nbsp;</p></em>&nbsp; <br />&gt; <p \
style="margin:0;padding:0;" class="im">&gt; <br />&gt; &gt; <br />&gt; &gt; Thanks<br \
/>&gt; &gt; <font color="#888888"><br />&gt; &gt; Mathilde<span style="color: \
#808000"></span><br />&gt;  &gt; <br />&gt; &gt; <a \
href="https://compte.laposte.net/inscription/index.do?jeux=2011FOOTER_generique" \
target="_blank"><img \
src="http://webmail.laposte.net/webmail/fr_FR/panels/images/pied-page-generique_2.jpg" \
/></a></font><br />&gt;  &gt;  _______________________________________________<br \
/>&gt; &gt;  Powered by <a href="http://www.kitware.com" \
target="_blank">www.kitware.com</a><br />&gt; &gt;  <br />&gt; &gt;  Visit other \
Kitware open-source projects at <a \
href="http://www.kitware.com/opensource/opensource.html" \
target="_blank">http://www.kitware.com/opensource/opensource.html</a><br />&gt;  &gt; \
<br />&gt; &gt;  Please keep messages on-topic and check the VTK FAQ at: <a \
href="http://www.vtk.org/Wiki/VTK_FAQ" \
target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br />&gt; &gt;  <br />&gt; &gt;  \
Follow this link to subscribe/unsubscribe:<br />&gt;  &gt;  <a \
href="http://www.vtk.org/mailman/listinfo/vtkusers" \
target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br />&gt; &gt;  <br \
/>&gt; &gt; </p></blockquote><p>&gt; </p><br />&gt; &gt; <p>&gt; </p> \
</blockquote><br />&gt; <br />&gt; <a \
href="https://compte.laposte.net/inscription/index.do?jeux=2011FOOTER_generique" \
target="_blank"><img \
src="http://webmail.laposte.net/webmail/fr_FR/panels/images/pied-page-generique_2.jpg" \
/></a></blockquote> </p><br />&gt; </p> </blockquote><BR><BR><a target=_blank \
href=https://compte.laposte.net/inscription/index.do?jeux=2011FOOTER_generique><img \
style="margin: 0pt;" \
src="http://webmail.laposte.net/webmail/fr_FR/panels/images/pied-page-generique_2.jpg" \
alt=""><a>



_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


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

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