Code Monkey home page Code Monkey logo

Comments (2)

lagru avatar lagru commented on June 26, 2024

Thanks for the report. I can reproduce this. Not sure right now about the best way to handle this because I'm not sure where the actual problem starts.

Does moments_central()[0, 0] being -1. make sense from an interpretation stand point?

from scikit-image.

aeisenbarth avatar aeisenbarth commented on June 26, 2024

I don't know. I don't use moments myself, and this is rather an outlier case.
This happens only with moments_weighted_normalized which receives mu from moments_weighted_central.
When comparing different labels and intensities,

>>> labels1 = np.array([[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]])
>>> labels2 = np.array([[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]])
>>> intensity_pos = np.full((5, 5), fill_value=1.0)
>>> intensity_0 = np.full((5, 5), fill_value=0.0)
>>> intensity_neg = np.full((5, 5), fill_value=-1.0)
>>> regionprops(labels1, intensity_pos)[0].moments_weighted_normalized
array([[       nan,        nan, 0.07407407, 0.        ],
       [       nan, 0.        , 0.        , 0.        ],
       [0.07407407, 0.        , 0.00548697, 0.        ],
       [0.        , 0.        , 0.        , 0.        ]])
>>> regionprops(labels1, intensity_neg)[0].moments_weighted_normalized
array([[        nan,         nan, -0.07407407,         nan],
       [        nan,  0.        ,         nan, -0.        ],
       [-0.07407407,         nan,  0.00548697,         nan],
       [        nan, -0.        ,         nan,  0.        ]])

If the normalization term is absolute (… / (np.abs(mu0) ** (sum(powers) / nu.ndim + 1)), it gives identical values for the positive case, and analog values without NaN for the negative case:

array([[        nan,         nan, -0.07407407,  0.       ],
       [        nan,  0.        ,  0.        , -0.       ],
       [-0.07407407,  0.        ,  0.00548697,  0.       ],
       [ 0.        , -0.        ,  0.        ,  0.       ]])

But this is just a guess. This would need someone to look deeper into the math.

from scikit-image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.