GithubHelp home page GithubHelp logo

Comments (9)

william-silversmith avatar william-silversmith commented on June 23, 2024

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.

william-silversmith avatar william-silversmith commented on June 23, 2024

@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.

selvakarna avatar selvakarna commented on June 23, 2024

@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.

william-silversmith avatar william-silversmith commented on June 23, 2024

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.

selvakarna avatar selvakarna commented on June 23, 2024

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.

william-silversmith avatar william-silversmith commented on June 23, 2024

from connected-components-3d.

william-silversmith avatar william-silversmith commented on June 23, 2024

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.

RylanSchaeffer avatar RylanSchaeffer commented on June 23, 2024

@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.

william-silversmith avatar william-silversmith commented on June 23, 2024

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)

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.