How to find sum of all pixels in rows whose value is 1 ?

1 次查看(过去 30 天)
I want to calculate the sum of all pixels in rows whose value is 1 in greyscale image

采纳的回答

Alex Mcaulley
Alex Mcaulley 2019-7-1
Being im your image:
sum(im==1,2)
  6 个评论
Jan
Jan 2019-7-1
@Nupur Goyal: "not work" is not a usefulö description of the problem. Please do not let the readers guess, what the problem is.
Grey scale images do not have 3 dimensions. So "(:,:,1) to (:,:,3)" means, that you do not have a grey scale image.
Alex's answer contains all you need: im==1 to get the indices and sum() to calculate the sum. Please try to combine these command until you get, what you want.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by