Commit aa271ecf authored by Sebastien Barre's avatar Sebastien Barre
Browse files

ENH: the pixel spacing was wrong. And ambiguous

parent 20baf892
......@@ -81,7 +81,10 @@ class VTK_IO_EXPORT vtkDICOMImageReader : public vtkImageReader2
vtkGetStringMacro(DirectoryName);
// Description:
// Returns the pixel spacing.
// Returns the pixel spacing (in X, Y, Z).
// Note: if there is only one slice, the Z spacing is set to the slice
// thickness. If there is more than one slice, it is set to the distance
// between the first two slices.
double* GetPixelSpacing();
// Description:
......
......@@ -778,15 +778,20 @@ void DICOMAppHelper::PixelSpacingCallback(DICOMParser *parser,
unsigned char* val,
quadbyte)
{
float fval = DICOMFile::ReturnAsFloat(val, parser->GetDICOMFile()->GetPlatformIsBigEndian());
if (group == 0x0028 && element == 0x0030)
{
this->PixelSpacing[0] = this->PixelSpacing[1] = fval;
if (!val || sscanf((char*)(val), "%f\\%f",
&this->PixelSpacing[0],
&this->PixelSpacing[1]) != 2)
{
this->PixelSpacing[0] = this->PixelSpacing[1] = 0.0;
}
}
else if (group == 0x0018 && element == 0x0050)
{
this->PixelSpacing[2] = fval;
this->PixelSpacing[2] =
DICOMFile::ReturnAsFloat(
val, parser->GetDICOMFile()->GetPlatformIsBigEndian());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment