Skip to content

Eccentricity computation differences with skimage #31

@joseantonio6894

Description

@joseantonio6894

Hi!

I was inspecting the eccentricity property for connected regions and found some discrepancies in the results compared to scikit-image (I was indeed trying to avoid a Python call with this package). For example, for this very simple region (which is a straight line, a fully elongated ellipse):

a = [0 0 0 0 0; 0 0 1 0 0; 0 1 0 0 0; 0 0 0 0 0; 0 0 0 0 0]
5×5 Matrix{Int64}:
 0  0  0  0  0
 0  0  1  0  0
 0  1  0  0  0
 0  0  0  0  0
 0  0  0  0  0

a_np = pyjl(a).to_numpy()
Python ndarray:
array([[0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 1, 0, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]])

region_props = skimage.measure.regionprops(a_np)
Python list: [<skimage.measure._regionprops.RegionProperties object at 0x7fdd988eb7d0>]

eccentricity_skimage = pyconvert(Float64, region_props[0].eccentricity)
1.0

eccentricity_jl = analyze_components(a, EllipseRegion()).eccentricity[1]
0.925820099772551

Results differ almost 10%. Additionally, if we rotate this line 45º, skimage eccentricity remains constant (as expected), but here the result is even more different:

a = [0 0 0 0 0; 0 0 1 0 0; 0 1 0 0 0; 0 0 0 0 0; 0 0 0 0 0]
5×5 Matrix{Int64}:
 0  0  0  0  0
 0  0  0  0  0
 0  1  1  0  0
 0  0  0  0  0
 0  0  0  0  0

a_np = pyjl(a).to_numpy()
Python ndarray:
array([[0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 1, 1, 0, 0],
       [0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]])

region_props = skimage.measure.regionprops(a_np)
Python list: [<skimage.measure._regionprops.RegionProperties object at 0x7fdd988eb7d0>]

eccentricity_skimage = pyconvert(Float64, region_props[0].eccentricity)
1.0

eccentricity_jl = analyze_components(a, EllipseRegion()).eccentricity[1]
0.8660254037844379

I've observed that there are some differences in the process to calculate the eccentricity, but I guess results should be somehow similar?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions