I want to know using either C/MATLAB , how to scan the image. I want to find out if there is any number of ones (1s) exist in the matrix.

For example:

Say, A matrix called M is 3x3. Now if M is a binary matrix:

M = [ 0 0 1; 0 0 0; 1 1 0];

By observing the matrix M, we know that there are three number of ones(1’s) in the matrix, right? I think there is some kind of code we can use: using for loops, if statements , and so on. I think the concept is simple that is if you see any 1’s in the matrix; send some type of message as an output.

HINT: we know the size of the matrix: So,

// size of the matrix M is: // size (M)

// int x=size of matrix;

// for ( int i=0, size of matrix)

// using if statement // we are using the condition that if ( 1) is found in the matrix,// send some type of message as an output may be a cout string.

Let me know if you understand the question, please.