Description
When constructing footprints (structuring elements) corresponding to a disk, the following code is currently used:
|
L = np.arange(-radius, radius + 1) |
|
X, Y = np.meshgrid(L, L) |
|
return np.array((X ** 2 + Y ** 2) <= radius ** 2, dtype=dtype) |
A second possibility is the following:
return np.array((X ** 2 + Y ** 2) <= (radius + 0.5) ** 2, dtype=dtype)
where the radius has been extended by 0.5 voxels. Practially the former means the edge of the disk falls at the voxel center a distance radius away, while for the later, the disk extends to the outer edge of that same voxel. A concrete illustration of this is given for radius = 3 (vs. 3.5) below:

Below is an illustration where the top row are the currently returned footprints for skimage.morphology.disk and the bottom row are the footprints with the proposed modification.

I don't know that the existing behavior is technically a bug, but it is more a matter of what convention is chosen. To me, the lower row look visually more disk-like (although radius=1 is too coarse to resemble a disk in either case).
If this change is made for disk, the same convention should be used for ball and ellipse as well.
Description
When constructing footprints (structuring elements) corresponding to a disk, the following code is currently used:
scikit-image/skimage/morphology/footprints.py
Lines 118 to 120 in d85b064
A second possibility is the following:
where the radius has been extended by 0.5 voxels. Practially the former means the edge of the disk falls at the voxel center a distance radius away, while for the later, the disk extends to the outer edge of that same voxel. A concrete illustration of this is given for radius = 3 (vs. 3.5) below:
Below is an illustration where the top row are the currently returned footprints for
skimage.morphology.diskand the bottom row are the footprints with the proposed modification.I don't know that the existing behavior is technically a bug, but it is more a matter of what convention is chosen. To me, the lower row look visually more disk-like (although radius=1 is too coarse to resemble a disk in either case).
If this change is made for
disk, the same convention should be used forballandellipseas well.