[vtkusers] question about vtkImageReslice speed

David Gobbi dgobbi at irus.rri.ca
Thu Jun 13 09:36:55 EDT 2002


Hi Luca, Zhang,

The speed problem with the sagittal slice has to do with how the
data is cached in memory.  Using vtkExtractVOI will not improve
the speed, in fact it might make things worse because you might have
to use vtkImagePermute to re-orient the slice image before you can
display it.

To speed things up, do this:

reslice->GetInput()->SetUpdateExtentToWholeExtent();
reslice->GetInput()->Update();

This will cache the entire image inside the input to vtkImageReslice.
You will notice a huge increase in speed.

Cheers,
 - David

--
  David Gobbi, MSc                       dgobbi at irus.rri.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

On Thu, 13 Jun 2002, Luca Antiga wrote:

> Dear Zhang,
> if I'm not wrong you look for 3 orthogonal views along the axes of your
> image, so you don't really need to reslice your dataset. I think you should
> better use vtkExtractVOI, or even method CopyAndCastFrom (vtkImageData*
> inData, int extent[6]) in vtkImageData, if you really want to speed up
> things. Of course if you want to obtain a transversal slice, you will need
> to use vtkImageReslice.
>
> Luca
>
> >From: "zhangzhijun" <zjzhang at ee.cuhk.edu.hk>
> >To: <vtkusers at public.kitware.com>
> >Subject: [vtkusers] question about vtkImageReslice speed
> >Date: Wed, 12 Jun 2002 22:50:40 +0800
> >
> >
> >Dear all:
> >         I use vtkImageReslice to get the 3 orthogonal views of a 3D image.
> >For axial, sagittal and coronal image I use 3
> >imagereslicer to get the image slice respectively. Then I change the image
> >slice index interactively by
> >adding or substracting the slice_index_x, slice_index_y and slice_index_z
> >by 1 then use the axial->SetResliceAxesOrigin(0,0,this->slice_index_z) etc
> >functions to refresh the new slice images. there is no problem with the
> >image displayed, the speed for the axial and coronal slices are quite ok
> >when I add or substract the image index by 1, but the speed for the
> >sagittal slice is much more slower then axial and coronal slices. is there
> >any reason for this?  Here is the code segment for this.
> >
> >void CDeformView::Addactors()
> >{
> >  axial=vtkImageReslice::New();
> >  axial->SetInput(imageData);
> >  axial->SetResliceAxesOrigin(0,0,0);
> >  axial->SetOutputDimensionality(2);
> >  axial->SetOutputSpacing(1,1,voxel_size_z);
> >  axial->InterpolateOn();
> >  axial->SetResliceAxesDirectionCosines(1, 0, 0,
> >                                           0, 1, 0,
> >                                           0, 0, 1);
> >  axial_mapper=vtkImageMapper::New();
> >  axial_mapper->SetInput(axial->GetOutput());
> >  axial_mapper->SetColorWindow(255);
> >  axial_mapper->SetColorLevel(127.5);
> >  vtkActor2D *axial_actor=vtkActor2D::New();
> >  axial_actor->SetMapper(axial_mapper);
> >  axial_actor->SetPosition(interval,interval);
> >  this->Renderer->AddActor(axial_actor);
> >
> >  sagittal=vtkImageReslice::New();
> >  sagittal->SetInput(imageData);
> >  sagittal->SetOutputDimensionality(2);
> >  sagittal->InterpolateOn();
> >  sagittal->SetResliceAxesOrigin(0,0,0);
> >  sagittal->SetOutputSpacing(1,1,voxel_size_x);
> >  sagittal->SetResliceAxesDirectionCosines(0,0,-1,
> >                                                                 0,1,0,
> >                                                                 1,0,0);
> >  sagittal_mapper = vtkImageMapper::New();
> >  sagittal_mapper->SetInput(sagittal->GetOutput());
> >  sagittal_mapper->SetColorWindow(255);
> >  sagittal_mapper->SetColorLevel(127.5);
> >  vtkActor2D *sagittal_actor=vtkActor2D::New();
> >  sagittal_actor->SetMapper(sagittal_mapper);
> >  sagittal_actor->SetPosition(2*interval+(width-1)*voxel_size_x,interval);
> >  this->Renderer->AddActor(sagittal_actor);
> >
> >
> >  coronal=vtkImageReslice::New();
> >  coronal->SetInput(imageData);
> >  coronal->SetResliceAxesOrigin(0,0,0);
> >  coronal->SetOutputDimensionality(2);
> >  coronal->InterpolateOn();
> >  coronal->SetOutputSpacing(1,1,voxel_size_y);
> >  coronal->SetResliceAxesDirectionCosines(1,0,0,
> >                                                                 0,0,1,
> >                                                                 0,-1,0);
> >  coronal_mapper = vtkImageMapper::New();
> >  coronal_mapper->SetInput(coronal->GetOutput());
> >  coronal_mapper->SetColorWindow(255);
> >  coronal_mapper->SetColorLevel(127.5);
> >  vtkActor2D *coronal_actor=vtkActor2D::New();
> >  coronal_actor->SetMapper(coronal_mapper);
> >
> >coronal_actor->SetPosition((depth-1)*voxel_size_z+(width-1)*voxel_size_x+3*interval,
> >
> >interval+((height-1)*voxel_size_y-(depth-1)*voxel_size_z)/2);
> >  this->Renderer->AddActor(coronal_actor);
> >}
> >
> >void CDeformView::OnSliceAxialup()
> >{
> >  this->slice_index_z++;
> >  axial->SetResliceAxesOrigin(0,0,this->slice_index_z);
> >  this->InvalidateRect(NULL,FALSE);
> >}
> >
> >void CDeformView::OnSliceAxialdown()
> >{
> >  this->slice_index_z--;
> >  axial->SetResliceAxesOrigin(0,0,this->slice_index_z);
> >  this->InvalidateRect(NULL,FALSE);
> >
> >}
> >
> >void CDeformView::OnSliceSagittalup()
> >{
> >  this->slice_index_x++;
> >  sagittal->SetResliceAxesOrigin(this->slice_index_x,0,0);
> >  this->InvalidateRect(NULL,FALSE);
> >}
> >
> >void CDeformView::OnSliceSagittaldown()
> >{
> >  this->slice_index_x--;
> >  sagittal->SetResliceAxesOrigin(this->slice_index_x,0,0);
> >  this->InvalidateRect(NULL,FALSE);
> >}
> >
> >void CDeformView::OnSliceCoronalup()
> >{
> >  this->slice_index_y++;
> >  coronal->SetResliceAxesOrigin(0,this->slice_index_y,0);
> >  this->InvalidateRect(NULL,FALSE);
> >}
> >
> >void CDeformView::OnSliceCoronaldown()
> >{
> >  this->slice_index_y--;
> >  coronal->SetResliceAxesOrigin(0,this->slice_index_y,0);
> >  this->InvalidateRect(NULL,FALSE);
> >}
> >
> >
> >regards,
> >zhang zhijun
>
>
> _________________________________________________________________
> MSN Photos is the easiest way to share and print your photos:
> http://photos.msn.com/support/worldwide.aspx
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>




More information about the vtkusers mailing list