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

fastremap.unique returns an incorrect counts if applied to a large image #37

Open
ivonindima opened this issue Apr 10, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ivonindima
Copy link

The function fastremap.unique returns an incorrect counts if applied to a large image. This happens on Windows if the number of voxels in any phase exceeds the maximum allowable value for np.uint32 (4_294_967_295).
For me the problem was solved by replacing uint32 with uint64 in unique_via_array.

import fastremap

N = 2500
img = np.random.randint(2, size=(N, N,N), dtype=np.uint8)
vals, counts = fastremap.unique(img, return_counts=True)
print(vals, counts/img.size) # Expected [0 1] [0.5 0.5]
@yojeep
Copy link

yojeep commented May 25, 2024

I have the same question

@william-silversmith william-silversmith added the bug Something isn't working label May 25, 2024
@william-silversmith william-silversmith self-assigned this May 25, 2024
@william-silversmith
Copy link
Contributor

For some reason, the obvious way to make this work with cython templates didn't work. I'm hesitant to simply just bump np.uint32 to np.uint64 because it will inflate memory usage significantly in some cases. Will think about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants