Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Count pixels of a black and white image (OpenCV / C++ )

I am a beginner to opencv / C ++ and would like your help with a problem that seems simple. As an example, I have this image:

image description

... And would disregard the background, which will always be white, and the image is always black and white, leaving only the cloud to be able to count three things:

  1. The number of pixels of the figure (cloud only, disregarding the background).
  2. The number of white pixels. (cloud only)
  3. The number of black pixels. (cloud only)

I know that to achieve 2, with a subtraction with it the 3rd.

Thanks!

click to hide/show revision 2
retagged

Count pixels of a black and white image (OpenCV / C++ )

I am a beginner to opencv / C ++ and would like your help with a problem that seems simple. As an example, I have this image:

image description

... And would disregard the background, which will always be white, and the image is always black and white, leaving only the cloud to be able to count three things:

  1. The number of pixels of the figure (cloud only, disregarding the background).
  2. The number of white pixels. (cloud only)
  3. The number of black pixels. (cloud only)

I know that to achieve 2, with a subtraction with it the 3rd.

Thanks!