What is the python module to count number of ones in a binary image ?
to rephrase,
I have a matrix that has only ones and zeros, it’s of numpy array type and I want to know how many ones are there.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can simply use
sum:Since bools have integer values of 0/1 for False/True, even if the array had elements that weren’t 0 or 1 you could use a variant of this trick: