[vtkusers] Extract slices from a vtkMetaImageReader with vtkExtractVOI

Jothy jothybasu at gmail.com
Thu Jun 30 10:19:17 EDT 2011


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
<mathilde.merle at laposte.net>wrote:

>
> I use *vtkImageViewer2 :*
> *
>     // VIEWER TOOL : Pick a Pixel
>     // Picker to pick pixels
>     vtkSmartPointer<vtkPropPicker> propPicker =
> vtkSmartPointer<vtkPropPicker>::New();
>     propPicker->PickFromListOn();
>
>     // Give the picker a prop to pick
>     vtkSmartPointer<vtkImageViewer2> imageViewer =
> vtkSmartPointer<vtkImageViewer2>::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 <
> mathilde.merle at laposte.net> 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
> >
> >
> <https://compte.laposte.net/inscription/index.do?jeux=2011FOOTER_generique>
> > _______________________________________________
> > 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
> >
> >
>
>
> >
>
>
>
> <https://compte.laposte.net/inscription/index.do?jeux=2011FOOTER_generique>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110630/c1b4c3e0/attachment.htm>


More information about the vtkusers mailing list