[vtkusers] vtkImageReslice & Extent & WholeExtent

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


Aha,

this is the first time that the difference between Extent and WholeExtent is made clear to me. Thanx. Maybe this should be mentioned in the documentation as well. (people at kitware...?)

Your hint about using the OutputSpacing, OutputOrigin and OutputExtent of my reslice filter is exactly how I solved the problem already. 

Thank you for the insight (and the excellent class vtkImageReslice)

Jorrit



19-11-2002 17:34:23, David Gobbi <dgobbi at imaging.robarts.ca> wrote:

>Hi Jorrit,
>
>The first time around your email slipped past me, thanks for
>bringing it up again.
>
>The ExecuteInformation method is not supposed to change the Extent,
>it is only supposed to change the WholeExtent.
>
>When the VTK image pipeline updates, the Mapper (or ImageActor or
>whatever is rendering the image) is usually only rendering one
>slice of the data.  So, the Mapper sets the UpdateExtent of its
>input data to just that slice.
>
>Then, when vtkImageReslice executes it only updates the UpdateExtent
>of its output and then sets its Extent to be the same as the
>UpdateExtent (actually the rules are a bit more complicated).
>
>In other words, the Extent is not necessarily the same as the
>WholeExtent (it isn't meant to be).  And the Bounds of the data
>reflect the Extent, not the WholeExtent.  In your case, the best
>bet is to compute the 'bounds' yourself using the OutputSpacing,
>OutputOrigin and OutputExtent of your reslice filter.  Another
>option is to call UpdateWholeExtent before calling GetBounds.
>
>I hope this helps,
>  - David
>
>
>
>On Tue, 19 Nov 2002, Schaap, J.A. (LKEB) 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
>
>





More information about the vtkusers mailing list