seung-lab / connected-components-3d

Connected components on discrete and continuous multilabel 3D & 2D images. Handles 26, 18, and 6 connected variants; periodic boundaries (4, 8, & 6)
GNU Lesser General Public License v3.0
356 stars 42 forks source link

largest_k fails for transposed arrays #112

Closed TheRealBazhen closed 1 year ago

TheRealBazhen commented 1 year ago

Hi! I faced a problem when using largest_k with transposed array - the result is nonsense. And during experiments with other functions (I tried connected_components) I did not face that problem. My cc3d version is 3.12.1

My minimal code:

import numpy as np
import cc3d
import matplotlib.pyplot as plt

strange = np.load('strange.npy')

plt.imshow(cc3d.largest_k(strange.transpose(2, 1, 0), 1)[100])
plt.imshow(cc3d.largest_k(strange, 1)[:, :, 100])
plt.imshow(cc3d.connected_components(strange)[:, :, 100])
image image image
william-silversmith commented 1 year ago

Hmm, I wasn't able to reproduce this with a simple test. Would you be willing to share an example image as an npy file?

TheRealBazhen commented 1 year ago

For sure, the file is here

william-silversmith commented 1 year ago

Thank you! I can reproduce this now.

william-silversmith commented 1 year ago

I found the bug. Will be fixing this!

TheRealBazhen commented 1 year ago

Great news, thank you!

william-silversmith commented 1 year ago

Released a new version. Let me know if you have any issues!