GithubHelp home page GithubHelp logo

Comments (4)

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

Hi Wenshuai!

It's possible to recover the labels using numpy.unique. The reason the ids are not contiguous is that the ids are assembled via merges in the union find algorithm. To get contiguous ids I'd have to renumber the array.

I didn't do this because I was stripping everything out to be as fast as possible, but it's probably a false economy as performing the renumber step is likely faster than calling np.unique.... however the fast way of doing it might use excessive memory, but I think I see a way of doing it with less on average.

I like your idea of assembling a region graph from the image, my lab might find that useful too. I'll try googling around first but if there's nothing convenient out there I'm happy to accept pull requests or write it myself, but I'm pretty busy so it's hard to say when it will be available.

from connected-components-3d.

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

@wenshuaizhao I just released version 1.2.0 which renumbers the array. There should be no performance penalty in memory or significant runtime from this change. You can now use np.max(cc_labels) to get the number of labels in the array, which is significantly faster and lower memory than np.unique.

It would be possible to return the max with the function and e.g. downsize the output datatype, but it requires me to change my C++ function to do multiple return and make a backwards incompatible change to cc3d's return value. I might do it in the future with a major version increment.

from connected-components-3d.

wenshuaizhao avatar wenshuaizhao commented on July 3, 2024

Thank you for your fast reply! I think I have made sense of such index. It is really great.

from connected-components-3d.

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

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.