Use one of the well known algorithm (look them up) to detect the edges in the image
Threshold this to get rid of noise.
Use another well known algorithm to thin the lines
Calculate start and end points to turn the lines into Vectors
Average the colours within the lines to get fills