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!
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.
Aneurysm_Detection/dataset_creation/utils_dataset_creation.py
Lines 989 to 996 in 70251d9
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!