InsightSoftwareConsortium / itk_cucim

ITK Python filters accelerated with cuCIM
Apache License 2.0
3 stars 3 forks source link

boundary handling conventions #3

Open grlee77 opened 2 years ago

grlee77 commented 2 years ago

scikit-image boundary handling names are unfortunately currently inconsistent across functions, but all filters use scipy.ndimage conventions. We plan to migrate all functions to use the same conventions in a future release.

From what I can tell there is the following equivalence between these ndimage names and ITK ones

skimage ITK
'constant' itk.ConstantBoundaryCondition
'nearest' (but skimage.transforms uses 'edge' instead!) itk.ZeroFluxNeumannBoundaryCondition
'wrap' itk.PeriodicBoundaryCondition

I didn't see an enum for a mirror boundary condition, but did see some comments in ITK code that BSplineInterpolateImageFunction uses that mode. Please update the table above if anything seems missing/wrong.

questions regarding ITK behavior

dzenanz commented 2 years ago

There is no mirror boundary condition, there is a mirror filter. I think that itk.ConstantBoundaryCondition does the equivalent of grid-constant, not constant. And generally ITK treats pixels as small hypercubes centered at the pixel position/index, see Figure 4.1 "Geometrical concepts associated with the ITK image." in section 4.1.4 of the ITK software guide.

thewtex commented 2 years ago

In general, is it the case that most filters in ITK use the itk.ZeroFluxNeumannBoundaryCondition or are there common cases where the boundary mode is user-selected?

This is the default for the ConvolutionImageFilter, which is a fairly primary filter, and Neumann is also used in many other filters.

The ResampleImageFilter is also a primary filters. It's behavior is to use a constant value by default when sampling outside the input domain. However, an Extrapolator can be set the behaves like Neumann.