Closed blchatel closed 3 years ago
Thank you for the report! I will look into this. I suspect it is due to an optimization that was probably fixed in 3d but maybe I forgot to port it to 2D.
On Thu, Jul 15, 2021, 8:29 AM Bastien Chatelain @.***> wrote:
Dear all,
Using cc3d for a while in python I just noticed single pixels are not labeled. At the beginning I though cc3d did not catch isolated pixels but the behavior is a little bit stranger :
import cc3d import numpy as np # NOT WORKING binary_img = np.zeros((3, 3), dtype=np.uint8) binary_img[1, 1] = 1 labels = cc3d.connected_components(binary_img, connectivity=4) print(f'{binary_img}\n => \n', labels) binary_img = np.zeros((5, 5), dtype=np.uint8) binary_img[1, 1] = 1 labels = cc3d.connected_components(binary_img, connectivity=4) print(f'{binary_img}\n => \n', labels) # WORKING binary_img = np.zeros((5, 5), dtype=np.uint8) binary_img[1, 1] = 1 binary_img[3, 3] = 1 labels = cc3d.connected_components(binary_img, connectivity=4) print(f'{binary_img}\n => \n', labels)
Corresponding outputs
[[0 0 0] [0 1 0] [0 0 0]] => [[0 0 0] [0 0 0] [0 0 0]] [[0 0 0 0 0] [0 1 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0]] => [[0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0] [0 0 0 0 0]] [[0 0 0 0 0] [0 1 0 0 0] [0 0 0 0 0] [0 0 0 1 0] [0 0 0 0 0]] => [[0 0 0 0 0] [0 1 0 0 0] [0 0 0 0 0] [0 0 0 2 0] [0 0 0 0 0]]
This issue may looks minor in most of the case but I use sometimes cc3d with very small 2D patches and this situation is happening.
Notice this issue seams not reproducible in 3D with third dimension bigger than 1
Best regards
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/seung-lab/connected-components-3d/issues/70, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATGQSJSQINXDFMCBCKSGZTTX3IC7ANCNFSM5ANOKZRQ .
I found the bug. C-order arrays are affected but not F order arrays. I'll work on releasing the fix, but in the meantime just do array = np.asfortranarray(array)
and it should work.
Perfect ! Thanks à lot for the quick answers !
Released this as version 3.2.1!
Dear all,
Using cc3d for a while in python I just noticed single pixels are not labeled. At the beginning I though cc3d did not catch isolated pixels but the behavior is a little bit stranger :
Corresponding outputs
This issue may looks minor in most of the case but I use sometimes cc3d with very small 2D patches and this situation is happening.
Notice this issue seams not reproducible in 3D with third dimension bigger than 1
Best regards