Comments (9)
Hi selvakarna, can you explain what you mean by 3D components? If you mean from an image processed with cc3d, obtain one of the components, you can do so like so:
cc_labels = cc3d.connected_components(labels)
one_label = (cc_labels == label_id) # e.g. label_id = 5
The README has a more detailed example here: https://github.com/seung-lab/connected-components-3d#python-use
If you are looking to create meshes from 3D image components, have a look at this package:
https://github.com/seung-lab/zmesh
from connected-components-3d.
@selvakarna, I hope your problem is solved! Let me know if I can close this issue. I'll assume it's resolved in five days.
from connected-components-3d.
@william-silversmith, while i got memory issue to use cc3d ? how to solve ? if any data types need to change?
my volume data= 1000 X 1200 X 7000 ~ 1000 X1200 X9000 ?
from connected-components-3d.
Can I ask how much RAM your machine has? If your data type is uint8, you could use about 50 GB maybe, but if the datatype is uint32, it would be 100 GB, and if uint64, 168 GB for the 7000 depth image. For the 9000 depth image, those numbers are 64 GB, 130 GB, and 216 GB.
You can try using the max_labels
parameter to reduce the allocation size of one of the arrays but your data are pretty big. This would be slow, but you can try mmapping a file and see if that helps. There are still a few ways I could improve cc3d to reduce the memory pressure, but the data are pretty big.
from connected-components-3d.
Hi @william-silversmith,, thanks for reply, is it any small changes in cc3d this parameter changes will reduce memory issue ? can share any parameters change in cc3d?
from connected-components-3d.
from connected-components-3d.
Hi Sevlakarna, I'm going to close your issues tomorrow if that's okay with you. Let me know if you need more help!
from connected-components-3d.
@william-silversmith I have a quick question. I also want to extract 3d components from binary 3d, albeit in a slightly different manner than what this author was talking about. By this, I mean the following.
Suppose I have a 3D array (I'll use 2D because easier to visualize) of binary values. I would like to know what the connected components are. For instance, I would like to take this binary input:
>>> labels_in
array([[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[1, 1, 1, 0, 0],
[1, 1, 0, 1, 0],
[1, 1, 0, 0, 1]], dtype=int32)
and convert it to the connected components, where the connected component have arbitrary labels i.e.
>>> labels_in
array([[1, 0, 0, 0, 0],
[0, 2, 0, 0, 0],
[2, 2, 2, 0, 0],
[2, 2, 0, 3, 0],
[2, 2, 0, 0, 4]], dtype=int32)
How do I do this using your library? Your library appears to presume that the inputs are the connected component labels, which is not true in my case.
from connected-components-3d.
Hi Rylan,
I believe you are requesting (assuming your example is 2D), a 4-connected neighborhood. The default is 8-connected, which would return a single fused component in the above example.
import numpy as np
import cc3d
labels_in = np.array(
[[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[1, 1, 1, 0, 0],
[1, 1, 0, 1, 0],
[1, 1, 0, 0, 1]], dtype=np.int32)
labels_out = cc3d.connected_components(labels_in, connectivity=4)
>>> print(labels_out)
[[1 0 0 0 0]
... [0 2 0 0 0]
... [2 2 2 0 0]
... [2 2 0 3 0]
... [2 2 0 0 4]]
labels_out = cc3d.connected_components(labels_in, connectivity=8)
>>> print(labels_out)
[[1 0 0 0 0]
... [0 1 0 0 0]
... [1 1 1 0 0]
... [1 1 0 1 0]
... [1 1 0 0 1]]
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.