forked from adetaylor/simple-image-recognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colourfinder.py
30 lines (25 loc) · 1.19 KB
/
colourfinder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
__author__ = 'adrian'
def find_blob(image, colour):
"""
Find the most substantial area of the given colour within the image.
The function searches for the largest area of the given colour, or a near colour,
within the image, and returns the location of the centre of that area of colour.
Should there be multiple areas of the colour within the given image, the algorithm will
return details of the largest.
When analysing the image the algorithm may have to choose between a large area of a vaguely
similar colour, or a small area of a more perfectly similar colour. In this situation
there are no guarantees about which blob it will specify. Such situations are best avoided
in the input image.
:param image: A 2D 'numpy' array of pixels
:param colour: The colour being searched for
:return: A tuple of (x, y, certainty) where x any are co-ordinates into the 2D array passed in,
and certainty is a value from 0.0 (colour not found at all) to 1.0 (perfect colour match found
at given location)
"""
# Claire - please implement!
return (0,0,0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (255, 0, 0)
YELLOW = (255, 255, 0)
PURPLE = (255, 0, 255)