[vtkusers] vtkImageGradient extent problem

Dean Inglis dean.inglis at camris.ca
Fri Apr 16 12:35:25 EDT 2004


if one wants to set a 2D slice input, other than
a xy-slice, to vtkImageGradient using vtkExtractVOI or vtkImageClip,
the gradient does not appear to be calculated correctly.

For example, suppose I had a 64x64x64 3D image with extents:
0,63,0,63,0,63 and I pulled out the middle y-z plane with
vtkImageClip to give extents: 0, 63, 31, 31, 0, 63.  Then
in vtkImageGradient:

<snip>
void vtkImageGradient::ExecuteInformation(vtkImageData *inData, 
                                          vtkImageData *outData)
{
  int extent[6];
  int idx;

  inData->GetWholeExtent(extent);
  if ( ! this->HandleBoundaries)
    {
    // shrink output image extent.
    for (idx = 0; idx < this->Dimensionality; ++idx)
      {
      extent[idx*2] += 1;
      extent[idx*2 + 1] -= 1;
      }
    }
<snip>

if HandleBoundaries is set to "On", I would expect that the
correct extents would be: 1, 62, 31, 31, 1, 62 but what is 
generated is 1, 62, 33, 30, 1, 63, which eventually leads to 
pixel access errors.  The filter's Execute method is not coded
to be used in the way I am trying to use it.  Should there be
a new gradient filter class, or, should the existing one be 
modified, or, should I be doing something different (i.e.,
is there a simple workaround?)? 

Dean




More information about the vtkusers mailing list