Comments (4)
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.
@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.
Thank you for your fast reply! I think I have made sense of such index. It is really great.
from connected-components-3d.
from connected-components-3d.
Related Issues (20)
- Applying Dust and largest_k dtype output option HOT 2
- dust sugnature HOT 1
- Massive memory Leak HOT 7
- 1D Array of 4 Elements Incorrect HOT 5
- Cannot find reference 'dust' in 'cc3d.py' HOT 2
- Question on comparing individual lesions between two masks based on the cc3d.statistics output. HOT 1
- Additional metrics support HOT 2
- Does cc3d also work with memmory-mapped numpy arrays and array-like data? HOT 14
- cc3d.statistics["bounding_boxes"] are wrong HOT 1
- largest_k fails for transposed arrays HOT 6
- About the lastest_k function HOT 4
- Statistics output HOT 7
- Question on the output of contacts HOT 9
- Periodic Boundary Conditions HOT 4
- Is the output label of largest_k ordered? HOT 2
- Add a better error for type support. HOT 4
- Any way to make this GPU Compatible? HOT 5
- voxel_connectivity_graph and contacts can not be applied in 2D label HOT 5
- Build Equivalence Table Two Z Slices at a Time
- cc3d.dust fails HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from connected-components-3d.