Bounding box of vtkImageData

@dgobbi Thanks a lot for the detailed explanation.

This definition of “bounds” is simple and it is always easy to compute, but quite misleading, as in many cases it coincides with actual bounding box of the data set but not always (for example for images and higher-order cells the actual bounding box can be larger).

I understand that it could be hard to change definition of bounds now (and computing points bounds is simple, while computing real bounds can be costly), so I don’t think it would be a good idea to change it, but at least this should be clearly documented so that users and developers do not incorrectly assume that a data set is always contained within its bounds. I’ll send a merge request with proposed API documentation update.

OK, this answers the main question: probe filter should be rewritten to work correctly for images. That new probe filter (and most imaging filters) does not use vtkImageData::GetBounds(), so it is fine that GetBounds() does not return the data set’s actual bounding box.

Yes, of course everyone “relies” on the current implementation in the sense that we could not change it without risking breaking many things. However, to get real boundaries of your image, you don’t use image “bounds” as is, but add half voxels to the bounds here and there.

I’ve been using VTK extensively for image processing and visualization for more than 10 years, but still have not realized this GetBounds behavior and its consequences. Most probably there are a couple of bugs in VTK (similar to the one in vtkProbeFilter) that is caused by this, but of course it is easier to fix them one by one than change image GetBounds behavior globally.

2 Likes