How to find the sum of each element of a matrix?

2 ビュー (過去 30 日間)
peyush
peyush 2015 年 6 月 28 日
コメント済み: peyush 2015 年 6 月 28 日
I have a binary image with some pixel values 1 and rest 0...I want to find out the sum of all the pixel values in the image...can any one help?

採用された回答

dpb
dpb 2015 年 6 月 28 日
If x is the array,
xsum=sum(x(:)); % ":" is a Matlab idiom that returns all elements in a column vector
  3 件のコメント
Image Analyst
Image Analyst 2015 年 6 月 28 日
That will work regardless of how many dimensions x has. By the way, a matrix is an array.
peyush
peyush 2015 年 6 月 28 日
thanks both of you :-)

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by