Image comparison algorithm, trying to figure out how similar two "binary" forms are



I'm a student I'm completely new to this technology maybe my approach could be completely wrong, I want to create an algorithm that compares the similarity between two binarized images.

I'll explain: I have 2 pictures as input. The RGB colors of these images can only be 0 or 255

(R = G = B = 255) or (R = G = B = 0). I take these two letters as an example.

1. symbol1 2. symbol2

I thought so: the 255 value is the background of the image which is white. The 0 value is the shape (letter) formed in the image. So I thought of creating a matrix with 0 and 1 values where value 0 represents the background and value 1 represents the shape.

So now i would like to create an algorithm that understands the shape created in the two matrices and that returns a similarity percentage.

Update: I'm creating this app that tries to recognize the font of a text in a image (, I want to create this algorithm to improve the comparison between the input letters and the alphabet of my fonts in the database.


Posted 2017-04-26T16:21:48.563

Reputation: 31

1I think you need to define what you mean by shape. One could compute the hamming distance between the images and get an answer but I don't think that is what you want. Try looking up convolutional NNs and MNIST. It should help. – Jaden Travnik – 2017-04-30T21:40:31.683



I think you look for the meaning of the image (pic of 'a' = a) rather than the regular image similarity. For example, you would like the two images of the 'a' you posted to be classified to the same label instead of, for example, to be classified as similar to an 'o' image which would give a smaller Hamming distance or mean square error.
So as @Jaden Travnik suggested, MNIST digits classification is a good start. It classifies handwritten digits and has human-level solutions implemented by any existing CNN framework. (TensorFlow, Caffe, Theano, to name a few).


Posted 2017-04-26T16:21:48.563

Reputation: 249