MATLAB: How to count numer of “1” in matrix

matrix operations

i have i matrix with 1/0 (binary img) and i want to count all "1" that are in that matrix. how can i do that??

Best Answer

The easiest way:
nr_ones = nnz(matrix);