[vtkusers] Display problems with vtkImageReslice

Henk Jonas MetaView at web.de
Tue May 15 04:23:38 EDT 2007


Hi list,

I'm using VTK 5.0.2 on Windows XP Home and try to reslice a volume.
The volume has 128 x 208 x 48 voxels. I try to display slice of the 
volume with a given alpha, beta and gamma. It basically works but I have 
some problerms or misunderstandings:
1. The picture doesn't fill the window. I can randomly alter some 
parameters SetOutputSpacing, SetOutputOrigin, SetOutputExtent to move 
the ouput around in the client area but I can't see how they are connected.
2. How to specify the size of the plane which I use to cut the volume? I 
want for example only extract a small part of the volume and fit it to 
the client area or have the whole volume fit.
3. I don't understand what the parameters stand for.
4. How to catch the mouse button down/up and mouse move events inside 
the render window?

How do I setup the reslice (nXSize, nYSize, nZSize are 128, 208, 48):

vtkImageReslice *m_vtkReslice;
vtkImageViewer2 *m_vtkImageViewer;

m_vtkReslice = vtkImageReslice::New();
m_vtkImageViewer = vtkImageViewer2::New();

vtkImageData *imageDataVolume = vtkImageData::New();
imageDataVolume->PrepareForNewData();
imageDataVolume->SetDimensions( 1, 1, 1 );
imageDataVolume->SetOrigin( -nXSize/2, 0, -nZSize/2 );
imageDataVolume->SetSpacing(1, 1, 1 );
imageDataVolume->SetExtent(0, nXSize-1, 0, nYSize-1, 0, nZSize-1 );

imageDataVolume->SetScalarType( VTK_UNSIGNED_CHAR);
imageDataVolume->SetNumberOfScalarComponents( 1);
imageDataVolume->AllocateScalars();

// then I fill the volume with values:
((BYTE *) imageDataVolume->GetScalarPointer(x,y,z))[0] = ptr3DVolume[(z 
* nZOffset) + ((nYSize - y - 1) * nXSize) + x];

// when done:
imageDataVolume->Update();

m_vtkReslice->SetInput((vtkImageData *) imageDataVolume);
m_vtkReslice->SetOutputExtent(0, nXSize, 0, nYSize, 0, 1);
m_vtkReslice->SetOutputDimensionality(2);
m_vtkReslice->SetInterpolationModeToCubic();

/* Initially set reslice axes and origin */
m_vtkReslice->SetResliceAxesDirectionCosines(1,0,0, 0,1,0, 0,0,1);
m_vtkReslice->SetResliceAxesOrigin(0,0,0);

m_vtkImageViewer->SetInput(m_vtkReslice->GetOutput());
m_vtkImageViewer->GetRenderWindow()->SetParentId((char *) 
GetDlgItem(IDC_RENDER_VIEW)->m_hWnd);
m_vtkImageViewer->Render();


later I only do
m_vtkReslice->SetResliceAxesDirectionCosines();
m_vtkReslice->SetResliceAxesOrigin();
m_vtkReslice->Update();

to move around.


Any help or info is much appreciated.

Thank you
Henk

-- 
-------------------------------------------------------------------------
   Henk Jonas
   Palm OS ® certified developer

   metaview at web.de                                   www.metaviewsoft.de
-------------------------------------------------------------------------



More information about the vtkusers mailing list