GithubHelp home page GithubHelp logo

Comments (7)

Karol-G avatar Karol-G commented on July 22, 2024

Hi William,

cc3d.statistics returns the lists voxel_counts, bounding_boxes and centroids. Does index 0 in each of the list correspond to component 1 (label 1) and so on or is it unordered? Maybe it would be better to return a list of dicts each with the entries label, voxel_counts, bounding_boxes and centroids? This would be similar to skimage.measure.regionprops and is in my opinion more intuitive. Also, it would make it easier to return more stats without getting too messy.

Best,
Karol

from connected-components-3d.

william-silversmith avatar william-silversmith commented on July 22, 2024

Hi Karol,

Thanks for writing in! The index into the list is the label ID (e.g. arr[label] for each of the properties). Index 0 is the background. This is similar to scipy.measure.find_objects except that in scipy, the first index corresponds to label 1, so you need to do arr[label-1] to get the right index. There was some discussion of this here: #94 I figured it would be more intuitive to not require any offset (and I was getting the statistics for label 0 anyway in one pass).

Array of objects vs object containing arrays is always debatable. I tend to favor object of arrays because then you can operate on the entire array efficiently. This is also the format used to actually perform the calculation internally for that reason (which is why the function is fast).

There might come a point when e.g. some labels might have calculated properties that others do not. I'll reconsider the interface as more properties are proposed. If there's a situation where you need statistics to be a drop-in replacement for regionprops, let me know and we can discuss some more. Maybe I could add in a compatibility function that translates the interface.

Will

from connected-components-3d.

Karol-G avatar Karol-G commented on July 22, 2024

Hi Will,

thanks for the quick reply!

Thanks for writing in! The index into the list is the label ID (e.g. arr[label] for each of the properties). Index 0 is the background. This is similar to scipy.measure.find_objects except that in scipy, the first index corresponds to label 1, so you need to do arr[label-1] to get the right index. There was some discussion of this here: #94 I figured it would be more intuitive to not require any offset (and I was getting the statistics for label 0 anyway in one pass).

Ah, I didn't assume that the background was also treated as a component. Thanks for the clarification!

Array of objects vs object containing arrays is always debatable. I tend to favor object of arrays because then you can operate on the entire array efficiently. This is also the format used to actually perform the calculation internally for that reason (which is why the function is fast).

Yes, you are right. It probably comes down to preference. I am team object-containing-array ;) but the current representation is fine as well with only three stats.

There might come a point when e.g. some labels might have calculated properties that others do not. I'll reconsider the interface as more properties are proposed. If there's a situation where you need statistics to be a drop-in replacement for regionprops, let me know and we can discuss some more. Maybe I could add in a compatibility function that translates the interface.

At the moment, I only need the bounding boxes so the current output is absolutly sufficient. But thanks for the proposition!

Best,
Karol

from connected-components-3d.

william-silversmith avatar william-silversmith commented on July 22, 2024

Anytime! You can always let me know if you have any questions or feedback about cc3d. Good luck on your project!

from connected-components-3d.

Karol-G avatar Karol-G commented on July 22, 2024

Thanks! Another question: Does the number of components, returned in connected_components when using the return_N parameter, also include the background component?

from connected-components-3d.

william-silversmith avatar william-silversmith commented on July 22, 2024

No, it only counts foreground labels.

from connected-components-3d.

Karol-G avatar Karol-G commented on July 22, 2024

Thanks!

from connected-components-3d.

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.