Skip to content

erode: potential bug with 3D strel_diamond #122

@korbinian90

Description

@korbinian90

I'm using the erode function with a diamond shape structuring element, but the output doesn't look like what I expected. I'm working with 3D masks. Here is a minimal example with 3x3x3 showing the unexpected result.

Explanation:
The center voxel image[2,2,2] should be 0 after erosion (It is connected to image[2,2,3]==0).
In the output of erode, the voxel eroded[2,2,2]==1 though, which is not what I expected.

julia> image = [1 1 1; 1 1 1; 1 1 1;;; 0 1 0; 1 1 1; 1 1 1;;; 0 0 0; 0 0 0; 1 1 1]
3×3×3 Array{Int64, 3}:
[:, :, 1] =
 1  1  1
 1  1  1
 1  1  1

[:, :, 2] =
 0  1  0
 1  1  1
 1  1  1

[:, :, 3] =
 0  0  0
 0  0  0
 1  1  1

julia> SE = strel_diamond(box)
3×3×3 ImageMorphology.SEDiamondArray{3, 3, UnitRange{Int64}, 0} with indices -1:1×-1:1×-1:1:
[:, :, -1] =
 0  0  0
 0  1  0
 0  0  0

[:, :, 0] =
 0  1  0
 1  1  1
 0  1  0

[:, :, 1] =
 0  0  0
 0  1  0
 0  0  0

julia> eroded = erode(image, SE)
3×3×3 Array{Int64, 3}:
[:, :, 1] =
 1  1  1
 1  1  1
 1  1  1

[:, :, 2] =
 0  1  0
 0  1  0
 1  1  1

[:, :, 3] =
 0  0  0
 0  0  0
 0  0  0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions