R
R
rubin33322021-09-09 19:45:54
Python
rubin3332, 2021-09-09 19:45:54

What does numpy.sum(img==1) mean in the Python numpy library?

I thought that the default value, but why are there then two = ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-09-09
@rubin3332

Counts the number of elements equal to "1"

>>> a = numpy.array([0,1,1,0,1,1,1,0,0,1])
>>> numpy.sum(a==1)
6
>>> numpy.sum(a==0)
4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question