So I have this bit of code
for x in range(x1,x2):
for y in range(y1, y2):
cpixel = pixels[x, y]
if bw:
bw_value = int(round(sum(cpixel) / float(len(cpixel))))
all_pixels.append(bw_value)
title = "Averaged (B&W) Pixel Values"
else:
if lumi:
luma = (0.3 * cpixel[0]) + (0.59 * cpixel[1]) + (0.11 * cpixel[2])
all_pixels.append(luma)
title = "Pixel Luminosity Values"
else:
if round(sum(cpixel)) / float(len(cpixel)) > 100:
all_pixels.append(255)
else:
all_pixels.append(0)
title = "Pixel Binary Transform Values"
taken and modified a bit from here Getting list of pixel values from PIL to give a list of pixel values (all_pixels) within a bounding region (user selected).
I'm trying to figure out an efficient way to detect changes within the list after a series of similar values have been recorded. Since the list seems to list the pixel values from top to bottom and left to right. In the scenario I will be using it in, it'll have a list of similar values until it hits a region of an image where the values will then begin to switch back and forth until the values once again stabilize around a new value.
What I'm interested in is tracking the boundary between these two, I want to detect where this boundary is and if it shifts left or right. I can't really think of any other way than having to check each value as it's appended to all_pixels and then just tracing back the coordinates.
But even this seems rather sketchy since even if I set an arbitrary number of values to be the same before the next one that's significantly different is seen as a significant change, not just an outlier, after that the values begin to toggle between the old values and the new ones.
I guess ideally I'd need to generate some sort of best fit line for the coordinates of this boundary region/line. I just need some ideas how to approach this problem.