[vtkusers] vtkImageReslice & Extent & WholeExtent

Schaap, J.A. (LKEB) J.A.Schaap at lumc.nl
Tue Nov 19 05:36:01 EST 2002


Hi David,

You didn't respond to the email below... I'm still quite convinced that this is a bug in vtkImageReslice. Would you be so kind to look into it? It won't take you more that 5 minutes, I'm sure of that.

Best regards, Jorrit



8-11-2002 15:14:12, "Schaap, J.A. (LKEB)" <J.A.Schaap at lumc.nl> wrote:

>Hi David,
>
>I'm not sure if this is a bug, or wheter I'm mis-using your excelent class.
>
>here's my code:
>
>imReslice->SetOutputExtent(0, dimensionsOfOutput[0]-1, 0, dimensionsOfOutput[1]-1, 0, dimensionsOfOutput[2]-1);
>imReslice->SetOutputSpacing(spacingOfOutput[0], spacingOfOutput[1], spacingOfOutput[2]);
>imReslice->SetResliceAxesOrigin(originOfLowerSlice[0], originOfLowerSlice[1], originOfLowerSlice[2]);
>imReslice->SetResliceAxesDirectionCosines(ortho1, ortho2, normal);
>imReslice->SetOutputOrigin(0, 0, 0);
>
>It reslices my box of dat into another box of data, and the results look perfect.
>If i ask however, imReslice->GetOutput()->GetBounds() then sometimes it gives the bounds of only one of the sides of the new box (so 2D) instead of 3D.
>When I step into imReslice->GetOutput()->GetBounds() then I get to the method vtkImageData::ComputeBounds() which reads as follows:
>
>void vtkImageData::ComputeBounds()
>{
>  float *origin = this->GetOrigin();
>  float *spacing = this->GetSpacing();
>  
>  this->Bounds[0] = origin[0] + (this->Extent[0] * spacing[0]);
>  this->Bounds[2] = origin[1] + (this->Extent[2] * spacing[1]);
>  this->Bounds[4] = origin[2] + (this->Extent[4] * spacing[2]);
>
>  this->Bounds[1] = origin[0] + (this->Extent[1] * spacing[0]);
>  this->Bounds[3] = origin[1] + (this->Extent[3] * spacing[1]);
>  this->Bounds[5] = origin[2] + (this->Extent[5] * spacing[2]);
>}
>
>
>I checked the origin and the spacing, they are correct. That's quite logical since I call the lines:
>imReslice->SetOutputOrigin(0, 0, 0);
>imReslice->SetOutputSpacing(spacingOfOutput[0], spacingOfOutput[1], spacingOfOutput[2]);
>
>The this->Extent is not ok however. One of the sides is 0, 0 so the whole box is 2D. If I look at this->WholeExtent then it looks ok to me. It's the same as it set it with the line 
>imReslice->SetOutputExtent(0, dimensionsOfOutput[0]-1, 0, dimensionsOfOutput[1]-1, 0, dimensionsOfOutput[2]-1);
>
>
>So I looked into the code of vtkImageReslice. The last lines of the method void vtkImageReslice::ExecuteInformation(vtkImageData *input, vtkImageData *output) read...
>
>  output->SetWholeExtent(outWholeExt);
>  output->SetSpacing(outSpacing);
>  output->SetOrigin(outOrigin);
>  output->SetScalarType(input->GetScalarType());
>  output->SetNumberOfScalarComponents(input->GetNumberOfScalarComponents());
>
>
>Shouldn't this be
>
>  output->SetWholeExtent(outWholeExt);
>  output->SetExtent(outWholeExt);
>  output->SetSpacing(outSpacing);
>  output->SetOrigin(outOrigin);
>  output->SetScalarType(input->GetScalarType());
>  output->SetNumberOfScalarComponents(input->GetNumberOfScalarComponents());
>
>so the Extent and the WholeExtent of the output are correct and always the same?
>
>Best regards, Jorrit Schaap
>
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>





More information about the vtkusers mailing list