Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_color(image: np.ndarray, rgb_color: list):
- """Count a quantity of pixel colors into an image
- Parameters
- ----------
- image: np.ndarray
- The numpy array image loaded as rgb channels
- rgb_color: list
- The color as [r, g, b] that you can count
- Returns
- -------
- The number of the pixel color into the image
- """
- rows, cols, depth = image.shape
- count = 0
- for row in range(rows):
- for col in range(cols):
- pixel = image[row][col]
- rgb = pixel.tolist()
- if rgb == rgb_color:
- count += 1
- return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement