2/15/2023 0 Comments White pixel checkThe first line says to extract and count all pixels from cv2 image object “img” whose pixel value is 255 i.e. Number_of_black_pix = np.sum(img = 0) # extracting only black pixels Number_of_white_pix = np.sum(img = 255) # extracting only white pixels This condition can be written in the NumPy as: This gives us a certain fixed condition of differentiation for the black and white pixels respectively from the other color pixels respectively. As we know that each pixel in a coloured image ranges from all-inclusive, the pixel value for the black color being 0 and that for the white color is 255. Now, a bit of knowledge of the pixel patterns comes into the picture. This sum() function can be used to count the number of pixels on the basis of the required criteria. NumPy provides a function sum() that returns the sum of all array elements in the NumPy array. To display OpenCV provides the imshow() method for displaying the image we have recently read.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |