[vtkusers] correction of spacing
Bartosz Wiklak
bwiklak at gmail.com
Mon Nov 24 12:37:42 EST 2008
Hello,
I'm using GDCM ( vtkGDCMImageReader ) to read some MR data.
I switched SetComputeZSpacing on, set SetZSpacingTolerance to 1e-2
and used IPPSorter.
This is my code:
vtkGDCMImageReader *reader = vtkGDCMImageReader::New();
std::vector<std::string> filenames;
gdcm::Directory d;
d.Load( "/home/basiek/Dokumenty/dcms/testGLOWA/1", false );
filenames = d.GetFilenames();
gdcm::IPPSorter s;
s.SetComputeZSpacing( true );
s.SetZSpacingTolerance( 1e-2 );
bool b = s.Sort( filenames );
if( !b )
{
std::cerr << "Failed to sort:" << "s" << std::endl;
return 1;
}
std::cout << "Sorting succeeded:" << s.GetZSpacing() << std::endl;
//s.Print( std::cout );
const std::vector<std::string> & sorted = s.GetFilenames();
vtkStringArray *files = vtkStringArray::New();
std::vector< std::string >::const_iterator it = sorted.begin();
for( ; it != sorted.end(); ++it)
{
const std::string &f = *it;
files->InsertNextValue( f.c_str() );
}
reader->SetFileNames( files );
reader->Update();
I'm getting zspacing 1.5 whitch is ok, but in the
reader->GetOutput()->GetSpacing(spacing) I'm getiing spacing[2]==1.0 !
What am I doing wrong?
I tried to set pixelspacing manually but after
reader->GetOutput()->UpdateInformation() I'm with old, wrong value
again.
When I make reslice in coronal I have eyes shaped like ellipses. I
tired to set pixelspacing for vtkImageReslice:
reslice->SetOutputSpacing( spacing[0], spacing[1], 1.5 );
but this also makes no difference regardless
reslice->GetOutput()->UpdateInformation().
Can someone point me in the right direction?
More information about the vtkusers
mailing list