Search code examples
imagealgorithmprocessingdetectionpixel

Fast algorithm required to detect changes in pixels


I am looking for an algorithm to detect changes in a pixel array. In the picture below, the red line illustrates the pixel array. I want the algorithm to recognize and trigger once the golf club below passes through the red line.

My original thought was to read the pixels along the line and to detect changes in color (specifically on the lower half of the line) when the color changes above a certain threshold.

Is there a better way to do this or an algorithm I can use which detects once the golf club passes the red line?

Thank you for your thoughts.

enter image description here


Solution

  • Tracking the pixels along the line is a feasible approach. I recommend not to check the pixels in the order top to bottom or bottom to top, I recommend a kind of interlacing order to increase the chance to detect a change with few pixel-checks.

    Here is what I mean:

    If the index the pixels from the to to the bottom by 0,1,2,3,..63 [just an example]

    I would check e.g. this order 0,32 ,16,48 ,8,24,40,56, 4,12,20,28,36,44,52,60, ...

    Or if you predict a non equal distributed probability for the change of the pixels, you can take even this in account and find an order of pixel checks with, detects the change with the lowest average pixel checks.