I want to calculate persentage of black pixels and white pixels for the picture, its colorful one
import numpy as np import matplotlib.pyplot as plt image = cv2
Keep variables for white_count and black_count and just iterate through the image matrix. Whenever you encounter 255 increase the white_count and whenever 0 increase the black_count. Try it yourself, if no success I'll post the code here :)
P.S keep the dimensionality of the image in mind