Skip to content
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

Visualization #56

Closed
Ademord opened this issue Nov 2, 2020 · 5 comments
Closed

Visualization #56

Ademord opened this issue Nov 2, 2020 · 5 comments
Labels
question Further information is requested

Comments

@Ademord
Copy link

Ademord commented Nov 2, 2020

Hello
I am trying to use your component, and i want to visualize the 3d plot. Sample from my code:

# 3D Plot
fig = plt.figure()
ax = plt.axes(projection="3d")

# depth_image = skimage.io.imread("/host/datasets/dataset1/depth_20201030T171046.png")
image = depth_image
# filter out points that are too far
idx = np.where((image != 0) & (image <= 230))

# visualize
x_points = idx[1]
y_points = 10*image[idx]
z_points = -idx[0]
col = np.arange(30)

ax.scatter3D(x_points, y_points, z_points, c=z_points, cmap='viridis');
plt.show()

Currently what I have is a depth image, with a separated rgb.
I want to do some 3d clustering and I have been reading a lot until I found your repo for 3d connected components.

Is there a way for me to visualize the results from code you have on your main README?

@Ademord
Copy link
Author

Ademord commented Nov 2, 2020

Also there doesnt seem to be any functional docs for using the repo on 2d images

@william-silversmith william-silversmith added the question Further information is requested label Nov 2, 2020
@william-silversmith
Copy link
Contributor

Hi Ademord,

Thanks for writing! I'm glad you are finding this library potentially useful.

Also there doesnt seem to be any functional docs for using the repo on 2d images

You can use 2D images just like 3D except that if you want to specify the 2D connectivity, you'll get better performance if you write connectivity=4 or connectivity=8 than with 6, 18, or 26 which are effectively 4, 8, and 8 when applied to 2D.

Currently what I have is a depth image, with a separated rgb.

cc3d only handles single channel images. To process it with cc3d, you'll need to convert the depth image from a 3-channel uint8 image (presumably) to a (u)int32 image with a single depth number per pixel.

Is there a way for me to visualize the results from code you have on your main README?

You can visualize the array in many different ways, but here is one:

pip install cloud-volume

import cc3d
from cloudvolume import view
out_labels = cc3d.connected_components(labels)
view(out_labels, segmentation=True)

That will generate a link to localhost:8080 and you can view the 3D volume by scrolling through it and reslicing different axes.

Will

@sneh-debug
Copy link

@william-silversmith how can we save the image obtained after applying cc3d?

@william-silversmith
Copy link
Contributor

You can also do:

from cloudvolume.lib import save_images
out_labels = cc3d.connected_components(labels)
save_images(out_labels)

@william-silversmith
Copy link
Contributor

Closing this issue due to lack of activity. Let me know if you still need help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants