vtkImageData interpolation on XZ and YZ images
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
After creating an image of dimensions (x,1,z), where x and y are integers larger than 1, interpolation via vtkProbeFilter began behaving incorrectly. Specifically, interpolating the points (0,0,0) and (0,0,10) would return the same value.
I found two bugs responsible for this behavior, both in the FindCell(...) function in vtkImageData.cxx:
1 - The cell indexing code assumes that the dimensions will be used in order (use XY instead of XZ). When a dimension is of size 1, the code assumes that there are zero cells/voxels in that direction. This is incorrect -- there is always at least one cell/voxel in each dimension. The computed indices for out-of-order dimensions are therefore incorrect, ignoring upper dimensions. To fix this, I simply check if any dimension is of size 1 and increment it before the cell index is computed. This should not affect in-order images, as the upper dimensions of their pixel indices are all zero.
2 - The interpolation weights assume that the dimensions will be used in order. They need to be shifted down to accommodate missing dimensions. This shifting is a bit tricky. It can be done in two passes. First, check the y dimension -- if it of size 1, shift all even-indexed blocks of weights to the front of the weights array. Second, check the x dimension -- if it is of size 1, shift all even-indexed weights to the front of the array. The z dimension can be ignored, as it clearly already works properly.
I have included the patch in the additional information section of this report.