Ancient secrets of computer vision
It's nice, but missing the most valuable (and simplest) take from computer vision: the Hough transforms.Let's take the circle Hough transform as it's one of the most enlightening ones!Say you are looking for a circle of a given diameter. After a binarization to make the edge stand out, make all the potential points "vote" for a circle center.The method is simple: using a matrix, you +1 all the points that are as far from this point as the radius of the circle will allow.Do this for every point, and take the max: https://en.wikipedia.org/wiki/Circle_Hough_TransformSimple, and works in guaranteed time.Extension 1: if you don't know the radius, apply iteratively for a range of values, then again, take the max: if you imagine how it works (or code it as an example then animate the result), it's like doing a "mathematical" focus.Extension 2: if it's too costly to do a dense exploration of the space of values for the radius, while you know there's only one circle, do a gradient descent on the increase.Extension 3: If there are more that one circle, other techniques exist - the easiest to picture are based on the maximization of variance of the distribution of values in the matrix resulting from the binarization, but you can also use 2d lattices and other fun tricks.