I want to identify a straight line in a picture (black/white, 0/1) and locate it so i already turned the picture into an 2d array with numpy and identified the line through calculating the average of the cell (a cell is a row in the 2d array, see source below). Now i would like to return the index (not the value) or at least the location of the cells which are not white.
I found a way to do so in a 1d array but going though the cells is faster than iterate though each pixel value. Till now i have something like this:
for cell in img_array: # the array is 2d and the values are 0 or 1
cal_average(cell) # selfmade function to calculate the average
if not cal_average(cell) == 1 : # condition to find the line
print('line found, it is here:', location) # not working outcome
Hope you know something. Thanks in advance!
Sources which i want to merge: