[vtkusers] FW: some questions about example Imagereslicing.cxx
xiaoyan juan
juanxiaoyan at hotmail.com
Wed Oct 27 21:34:35 EDT 2010
> From: david.gobbi at gmail.com
> Date: Wed, 27 Oct 2010 10:41:16 -0600
> Subject: Re: [vtkusers] some questions about example Imagereslicing.cxx
> To: juanxiaoyan at hotmail.com
> CC: vtkusers at vtk.org
>
> 2010/10/26 晓彦 隽晓彦 <juanxiaoyan at hotmail.com>:
> > i find the value of SetDataSpacing is not used when read the 2D CT images
> > using vtkImageReader2, but i want to read 2D CT images as 3D according to
> > value of SetDataSpacing in order to extract a interpolated slice in desired
> > orientation. i wonder it can be implemented? i will appreciate any answer
> > from you. thank you.
> >
> > some program of the example is as follows:
> > vtkImageReader2 *reader = vtkImageReader2::New();
> > reader->SetFilePrefix(argv[1]);
> > reader->SetDataExtent(0, 63, 0, 63, 1, 93);
> > reader->SetDataSpacing(3.2, 3.2, 1.5);
> > reader->SetDataOrigin(0.0, 0.0, 0.0);
> > reader->SetDataScalarTypeToUnsignedShort();
> > reader->UpdateWholeExtent();
>
> The image reader cannot do any reslicing. The SetDataSpacing() method
> tells VTK that the pixels in the file are 3.2mm by 3.2mm and that the
> slices are 1.5mm apart, because VTK needs this information in order to
> correctly render the data. To reslice the data, you must add a
> vtkImageReslice filter or a vtkImageResample filter after the reader.
>
> I might have misunderstood your question, but I hope that my answer is helpful.
>
> David
thanks David!
Because i want to get the resliced data extracted using vtkImageReslice in order to write the display program by myself. so i have another questions.
1) VTK don't needs SetDataSpacing() method before rendering the data, so do the image reader method?
2) According to the below program, if 1) is true, i can understand why the size of the data of sagittalData is 64×93 instead of 64×3.2×93×1.5. and it is the true that the sagittalData is extracted from CT images directly without considering the DataSpacing , but it is clear that extracted reslice is bad, because the CT images are not interpolated according to the value of SetDataSpacing().
////////////////////////////////////////////////////////// Set the slice oobliquerientation////////////////////////////////////////////////////
vtkMatrix4x4 *resliceAxesSagittal = vtkMatrix4x4::New();
resliceAxesSagittal->DeepCopy(sagittalElements);
// Extract a slice in the desired orientation
vtkImageReslice *resliceSagittal = vtkImageReslice::New();
resliceSagittal->SetInputConnection(v16->GetOutputPort());
resliceSagittal->SetOutputDimensionality(2);
resliceSagittal->SetResliceAxes(resliceAxesSagittal);
resliceSagittal->InterpolateOn();
//resliceSagittal->SetInterpolationModeToLinear();
resliceSagittal->Update();
////////////////////////////////////////extract the data of sagittal////////////////////////////////////////////////////////
if(resliceSagittal->GetOutput()->GetScalarPointer()==NULL){
resliceSagittal->GetOutput()->AllocateScalars();
}
unsigned short *ptrdb=(unsigned short *)resliceSagittal->GetOutput()->GetScalarPointer();
memcpy(sagittalData,ptrdb,64*93*sizeof(unsigned short));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101028/63e41093/attachment.htm>
More information about the vtkusers
mailing list