<div dir="ltr">Which image viewer are you using here?<br><br>Jothy<br><br><div class="gmail_quote">On Thu, Jun 30, 2011 at 3:41 PM, mathilde.merle <span dir="ltr"><<a href="mailto:mathilde.merle@laposte.net">mathilde.merle@laposte.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><p style="margin:0;padding:0" align="left"><br></p><br>Hello,<br><br>I'm trying to extract slices from a vtkImagedata sequence and then display it. <br>
<br>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><br>How can I do ?<br><br>My code :<br><i><br>int* dims = reader->GetOutput()->GetDimensions();<br>
<br>// extract slice<br><br><b>int slice_nb = 0;</b><br><br><b>vtkSmartPointer<vtkExtractVOI> extractVOI = vtkSmartPointer<vtkExtractVOI>::New();<br> extractVOI->SetInputConnection(reader->GetOutputPort());<br>
extractVOI->SetVOI(0,dims[0],0,dims[1], slice_nb, slice_nb); //extract first image<br> extractVOI->Update();</b><br> <br> vtkImageData* extracted = extractVOI->GetOutput();<br><br> int* dims2 = extracted->GetDimensions();<br>
cout << "DimensionsExtracted = ";<br> for (int i=0; i<(int)(sizeof(dims2)/sizeof(int)+1); i++) { <br> cout << dims2[i]<<", ";<br> }<br> cout << endl; // Get a good image dimension<br>
<br>// Visualize<br> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();<br> imageViewer->SetInputConnection(<b>extractVOI->GetOutputPort() </b>);<br>
imageViewer->SetupInteractor( renderWindowInteractor );<br> imageViewer->SetSize( 600, 600 );<br> <br> vtkRenderer* renderer = imageViewer->GetRenderer();<br> renderer->ResetCamera();<br> renderer->GradientBackgroundOn();<br>
renderer->SetBackground(0,0,0);<br> renderer->SetBackground2(1,1,1);<br> <br> // Annotate the image with window/level and mouse over pixel information<br> vtkSmartPointer<vtkCornerAnnotation> cornerAnnotation = vtkSmartPointer<vtkCornerAnnotation>::New();<br>
cornerAnnotation->SetLinearFontScaleFactor( 2 );<br> cornerAnnotation->SetNonlinearFontScaleFactor( 1 );<br> cornerAnnotation->SetMaximumFontSize( 20 );<br> cornerAnnotation->SetText( 0, "Off Image" );<br>
cornerAnnotation->SetText( 3, "<window>\n<level>" );<br> cornerAnnotation->GetTextProperty()->SetColor( 1,0,0);<br> <br> imageViewer->GetRenderer()->AddViewProp( cornerAnnotation );<br>
<br> // Callback listens to MouseMoveEvents invoked by the interactor's style<br> vtkSmartPointer<vtkImageInteractionCallback> callback = vtkSmartPointer<vtkImageInteractionCallback>::New();<br> callback->SetViewer( imageViewer );<br>
callback->SetAnnotation( cornerAnnotation );<br> callback->SetPicker( propPicker );<br> callback->SetOrigin( orgn[0], orgn[1], orgn[2]); // add the origin of the sequence into the class<br><br> // Events recognized <br>
vtkInteractorStyleImage* imageStyle = imageViewer->GetInteractorStyle();<br> imageStyle->AddObserver( vtkCommand::MouseMoveEvent, callback );<br> imageStyle->AddObserver( vtkCommand::LeftButtonReleaseEvent, callback );<br>
<br> renderWindowInteractor->Initialize();<br> renderWindowInteractor->Start(); </i> <br><br><br>Thanks<br><font color="#888888"><br>Mathilde<span style="color:#808000"></span><br><br><a href="https://compte.laposte.net/inscription/index.do?jeux=2011FOOTER_generique" target="_blank"><img style="margin:0pt" src="http://webmail.laposte.net/webmail/fr_FR/panels/images/pied-page-generique_2.jpg" alt=""></a><a></a></font><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
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>
<br>
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>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>