Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

How to use np.count_nonzero() within a range of pixels?

$
0
0
Hi there! I am working on a script that reads the non-zero pixels in a binary image. I am using np.count_nonzero() to count non zero pixels, which works fine until, I specify a range of coordinates. ele = np.count_nonzero(img) Works fine But, when I specify a range of pixels, for example I am working with a 640*480 res image, Now I want that only the pixels falling in the range of (320,0) and (640,480), that is, the right half, be checked for non zero values, so I modify my code to - ele = np.count_nonzero(((320,0) ValueError: operands could not be broadcast together with shapes (480,640) (2,) To me it sounds like the image layers (RGB or similar) might be causing this problem. Can anyone tell me how to fix it?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>