[vtkusers] ImageReslice to data

jose manjon jmanjon at fis.upv.es
Fri Jun 14 14:39:42 EDT 2002


Hi all,

I am using vtkImageReslice class to get arbitrary planes from my 256x256x165 mri volume

I have used the sample (data is a vtkStructuredPoints volume ):

 vtkTransform* transform=vtkTransform::New();
 transform->RotateX(90);
 transform->RotateY(90);
 transform->RotateZ(90);

 vtkImageReslice* reslice=vtkImageReslice::New();
 reslice->SetInput(data);
 reslice->SetResliceTransform(transform);
 reslice->InterpolateOn();
 reslice->SetOutputSpacing(pDoc->resx,pDoc->resy,pDoc->resz);
 reslice->SetBackgroundLevel(0);
 reslice->GetInput()->SetUpdateExtentToWholeExtent();  // to speed up
 reslice->GetInput()->Update();

 vtkImageViewer * viewer=vtkImageViewer::New();
 viewer->SetInput(reslice->GetOutput());
 viewer->SetZSlice(122);
 viewer->SetColorWindow(128);
 viewer->SetColorLevel(128);
 viewer->Render();


and all works perfect ....  but I dont want to show the results on a vtkImageViewer window. I want to show the results on my MFC view (VC++6.0).
For this reason I have tried to extract the resliced image for painting it on a view.

I do this:


int ca=132;

vtkTransform* transform=vtkTransform::New();
 transform->RotateX(0);
 transform->RotateY(80);
 transform->RotateZ(0);

 reslice=vtkImageReslice::New();
 reslice->SetInput(data);
 reslice->SetResliceTransform(transform);
 reslice->InterpolateOn();
 reslice->SetOutputSpacing(pDoc->resx,pDoc->resy,pDoc->resz);
 reslice->SetBackgroundLevel(0);
 reslice->GetInput()->SetUpdateExtentToWholeExtent(); // to speed up
 reslice->GetInput()->Update();

 vtkImageData * ima=reslice->GetOutput();
 ima->Update();    // very slow !!!

 int dim[3];
 ima->GetDimensions(dim);

 unsigned short * puntero=(unsigned short *)ima->GetScalarPointer();

 for(i=0;i<dim[0]*dim[1];i++) Bitmap[i]=puntero[ca*dim[0]*dim[1]+i];

// showing stuff ....


the problem is that Image is not correct , and I dont now why?
I use the for like a GetZslice funtion but no way....

any idea???

thanks

jose


##########################################################

        Prof.  Jose Vicente Manjón Herrera

        Dept. Fisica Aplicada
        Escuela Universitaria de Informatica
        Universidad Politécnica de Valencia

##########################################################





More information about the vtkusers mailing list