Yes, it is possible!
For example, you can take pixel by pixel comparison and apply MSE (mean square error). If the error is close to zero, it is the same picture.
However, you will be able to recognize only those images which are picture perfect matching. For example, you won't be able to account for brightness variations, scale variations, minor transformations, compression loss (e.g. JPEG) etc. So while human being might just see them as SAME image - they are not on every pixel basis. Depending on how much strict or tolerant your application needs to be, do we really need to then look for advanced algorithms that are smart enough to be invariant to these factors.
EDIT:
After your clarification, it does sound like you have more of a special case of matching rather than general purpose recognition problem.
Given the following assumptions:
A gray scale (or color) images are first converted to binary through some thresholding process.
Mostly these images are lines (thick or thin) and the key differentiation is how far these edges are from others.
Edges could be of arbitrary shapes and contours -no geometrical assumptions.
Given the edge detection limitations (in the presence of noise) and thresholding algorithms, edges might be disjoint
Here is what i would suggest to apply:
Edge following algorithms - to make continuous edges where applicable.
Ref #1. http://www.slideshare.net/kiara1011000/edge-following-algorithm-chiara-galdi
Apply Housdourf distances and similar shape/contour matching
Ref #1. Haudorff Distance by Normad
Ref #2. CV Online: The Hausdorff Distance
Ref #3. Hausorff based Matching
Basic idea is that if all edges are more or less at the same locations and of same length, then the images are same.
Given that large portion of region which contains Black and implies no information- MSE would be an extremely BAD idea.
I am only giving you some basic direction toward formulating your problem. As you dig deeper you can put more specific questions. I would be keen to know what works for you finally.
EDIT 2: Adding one specific solution
One simple possible metric i can think of is:
Say, Ref[i][j]
is the reference image and Test[i][j]
is the test image.
pixel_similarity = 0;
For each pixel in Ref[i][j]
{
if ( Ref[i][j] == Edge_pixel )
(k,l) <- find_nearest_edge_pixel(Ref, Test, i, j, window_size)
pixel_similarity += weighted_similarity (i, j, k, l)
}
image_similarity_metric = error / (total_edge_pixels_in_ref);
Please Note that this algorithm will be quite limited for heavy scaling and rotation. This is first step. Notify me for any typo or lack of clarity!
Observations:
If you keep two identical images (pixel by pixel)- you will find that (k,l) will be same as (i,j) and weighted error should be = 1.
By dividing the number of edge pixels by total edge population, you will get similarity metric = 1.0 for perfectly matching images.
When edges are almost similar, but slightly misaligned score will decline gradually. The weighted_similarity
function should be chosen smartly to deal with what you consider as reasonably aligned edge vs. one that should be discarded.
Other extreme is that if total number of edge pixels in Ref is zero - there is no way to compare it with any other one (since we are considering background pixels having no information related to match).
Try to work this out and see what results you get.
Happy to help you!