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

Most efficient way to determine the number of non-zero entries of a CImg? #426

Open
nji9nji9 opened this issue Aug 26, 2024 · 1 comment

Comments

@nji9nji9
Copy link

Is there a member function to use, or do I have to iterate
pixel-by-pixel myself?
Probably code it with vector ops at the internal structure...?

@GreycLab GreycLab deleted a comment Aug 26, 2024
@GreycLab GreycLab deleted a comment Aug 26, 2024
@dtschump dtschump reopened this Aug 26, 2024
@nji9nji9 nji9nji9 changed the title Most efficient way to determine the non-zero entries of a CImg? Most efficient way to determine the number of non-zero entries of a CImg? Aug 27, 2024
@dtschump
Copy link
Collaborator

I'd say :

  const unsigned int nb_non_zeros = img.size() - img.get_histogram(1,0,0)[0];

A bit tricky, but concise enough :)

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