If you have a continuos line you could replace it by using an A* search algorithm, That way you would find any hole lines:
WPF: A* search[
^]
Then you could simplify the line by using Douglas-Peucker or simular algorithm:
Polyline Simplification[
^]
Now it would just be a metter of finding simular shapes.
PS: Assuming the pictures are Soble or Canny edge detection?