-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to extract 3D components from Binary 3D using cc3d package? #23
Comments
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: |
@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. |
@william-silversmith, while i got memory issue to use cc3d ? how to solve ? if any data types need to change? |
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 |
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? |
Hi selvakarna,
It's a little difficult for me to give the correct recommendation without
knowing your RAM size, but your best bet is to try:
```
cc_labels = cc3d.connected_components(labels, max_labels=(labels.size // 8))
```
However, in the best case (input datatype is 64-bit), this will reduce your
memory usage by 2/5. In the worst case, it would be by 1/6. If I decrease
the output data type from uint32 to uint16, that could help (an additional
1/10 to 1/3 improvement), but your arrays are so large that without knowing
your RAM and input datatype I'm not sure if it would help or not.
Have you considered using cloud instances? It's possible to get very large
RAM instances there for fairly cheap on an hourly basis.
Also, just for my own curiosity, what kind of field are you working in?
Those kinds of huge images aren't very common (though I see similar images
in my field of high resolution brain imaging).
I hope you find something useful in this advice!
Will
|
Hi Sevlakarna, I'm going to close your issues tomorrow if that's okay with you. Let me know if you need more help! |
@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:
and convert it to the connected components, where the connected component have arbitrary labels i.e.
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. |
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]] |
How to extract 3D components from Binary 3D using cc3d package?
The text was updated successfully, but these errors were encountered: