Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check_colors(image, reference_colors = [[128, 0, 0], [0, 0, 128], [0, 0, 0]]):
- colors_on_image = set( tuple(v) for m2d in image for v in m2d )
- if len(colors_on_image) != 2:
- return False
- for color in colors_on_image:
- if not np.any(reference_colors == color):
- return False
- return True
- def check_object_sizes(image, objects_colors = [[128, 0, 0], [0, 0, 128]], tresh = 0.1):
- mask = np.full(image.shape, False, dtype = bool)
- for color in objects_colors:
- mask = np.logical_or(mask, image == color)
- return ((mask.sum() / np.prod(image.shape)) >= tresh)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement