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

Possible Performance Improvement #2

Open
william-silversmith opened this issue May 26, 2022 · 3 comments
Open

Possible Performance Improvement #2

william-silversmith opened this issue May 26, 2022 · 3 comments

Comments

@william-silversmith
Copy link

Hi! I was browsing repos that were using cc3d recently to see how people are using it. I noticed in your repo that there was a spot that looked slow that could be improved fairly easily.

labels_out = cc3d.connected_components(np.asarray(hard_threshold_patch, dtype=int))
numb_labels = np.max(labels_out) # extract number of different connected components found
numb_non_zero_voxels = []
for seg_id in range(1, numb_labels + 1): # loop over different labels (i.e. conn. components) found
extracted_image = labels_out * (labels_out == seg_id) # extract one conn. component volume
numb_non_zero_voxels.append(np.count_nonzero(extracted_image)) # append number of non-zero voxels for this conn. component volume
largest_conn_comp_value = np.argmax(numb_non_zero_voxels) + 1
largest_conn_comp_binary = hard_threshold_patch * (labels_out == largest_conn_comp_value)

        largest_conn_comp_binary = cc3d.largest_k(labels_out, k=1)

If that's not useful to your project, please feel free to ignore this as I don't want to waste your time. Good luck!

@tommydino93
Copy link
Collaborator

Hi @william-silversmith! thanks for pointing this out, and for developing cc3d! I find it very useful.

For the moment, I saw that the newest version of cc3d requires python 3.7, while I still have everything on 3.6. I will keep this in mind when upgrading to 3.7 :)

@william-silversmith
Copy link
Author

william-silversmith commented May 26, 2022 via email

@tommydino93
Copy link
Collaborator

You are right! I will upgrade and make the modifications. Leaving this issue open as a reminder until I am done :)

Thanks again
Tommaso

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

No branches or pull requests

2 participants