You could use one of the solutions mentioned here to read in an image to a numpy array: Importing PNG files into Numpy?
And then you could use the numpy.argwhere
function numpy.argwhere(image_array > treshold)
to return the indices where the gray value is larger than some threshold
import matplotlib.pyplot as plt
import numpy as np
im = plt.imread('3zu5i.png')
#https://stackoverflow.com/questions/12201577/how-can-i-convert-an-rgb-image-into-grayscale-in-python
def rgb2gray(rgb):
return np.dot(rgb[...,:3], [0.2989, 0.5870, 0.1140])
grey = rgb2gray(im)
coordinates = np.argwhere(grey < 0.99)
That should return an array containing the array indices with grayscale values larger than some threshold
array([[ 41, 280],
[ 41, 281],
[ 41, 282],
...,
[372, 299],
[372, 300],
[372, 301]])