[vtkusers] FW: some questions about example Imagereslicing.cxx
xiaoyan juan
juanxiaoyan at hotmail.com
Wed Nov 3 01:24:41 EDT 2010
Hi david!
i make a apology that i did't explain the question on reslice clearer to you last time, and want to ask some question in another way as follows.
1. i wonder if the data which is resliced is associated with DataSpacing?
2. SetInterpolationModeToLinear is executed when relice the data?
3. according to below program in which i add the extraction of data of sagittal based on Imagereslicing.cxx, why size of the data of sagittal is 64*93 but size of the displayed image seems be 64*3.2*93*1.5?
thanks very much!
////////////////////////////////////////////////////////// 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////////////////////////////////////////////////////////
unsigned short *ptrdb=(unsigned short *)resliceSagittal->GetOutput()->GetScalarPointer();
memcpy(sagittalData,ptrdb,64*93*sizeof(unsigned short));
From: juanxiaoyan at hotmail.com
To: vtkusers at vtk.org
Date: Thu, 28 Oct 2010 09:34:35 +0800
Subject: [vtkusers] FW: some questions about example Imagereslicing.cxx
> 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);
> > r eader->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){
&nbs p; resliceSagittal->GetOutput()->AllocateScalars();
}
unsigned short *ptrdb=(unsigned short *)resliceSagittal->GetOutput()->GetScalarPointer();
memcpy(sagittalData,ptrdb,64*93*sizeof(unsigned short));
_______________________________________________ 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101103/5a0cb59f/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ATT00001
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101103/5a0cb59f/attachment.txt>
More information about the vtkusers
mailing list