I've been going through posts and examples for the past two days and all snippets Ive tried and extensively tested have proven to be quite useless, at least for my purposes.
What I want to do is compare a black vector symbol photographed off a wall or piece of paper (quality akin to badly scanned images one might say) and compare that to an electronic version of the same or similar symbol (which would be stored locally and compared to the photograph). Please take a look at the two attached images, the first clean one (reference image) is the database version of the symbol and the second is a crappy drawing I made on a piece of paper which I then photographed with my iPad.
I wanted the procedure to go as follows:
- The two images are loaded and then trimmed using a modified version of this trimming algorithm I found here: Trimming images with PIL. I found that a 'threshold' value of 50 and an 'obviousness' value of 20 (parameters in the linked script) give good results for these images
- The images would then be resized to the same size and compared
Now for the comparison, I've tried a ton of different suggested approaches but so far the results are terrible. I can actually get better comparison results with a random image than the tested one. I've tried RMS difference comparison based on the actual images, their edges (created with the 'filter' function with ImageFilter.CONTOUR or ImageFilter.FIND_EDGES), Pixel-Based Comparison but so far nothing Ive found online (despite my incessant googling) or here in StackOverflow has given me decent results.
I believe that the problem lies in the noisy backdrop of the test image but I havent been able to prove it. Does anyone know if there's a way to get a vectorial outline out of the edges in these images and compare them not merely as images but as image-vectors? Despite my crappy drawing, I find that these two images are fairly similar and it should be possible to get a good comparison out of it.