Karthik
Karthik

Reputation: 1

Image comparison algorithm

Can anyone suggest an algorithm for image comparison?

Upvotes: 0

Views: 4825

Answers (2)

Andy Jackson
Andy Jackson

Reputation: 356

If you want to compare the image itself, I can recommend well-established comparison metrics like Peak signal-to-noise ratio (which is very widely used), or perhaps the Structural Similarity Index (which aims to more closely model the kind of difference that the human eye notices). I would recommend re-using existing implementations, as the large summations these algorithms require are difficult to get right (in short, use BigInteger instead of long or double accumulators).

Also, note that two images may encode the same image using different colour-spaces, so you probably want to ensure both images are transformed to use the same colour-space before comparing them. Of course, if the image is shifted or otherwise modified, you'll need to use some form of feature recognition - see the Image comparison algorithm post w69rdy referred to.

Upvotes: 1

Svisstack
Svisstack

Reputation: 16616

bool compare(unsigned char* f, size_t fs, unsigned char* s, size_t ss)
{
    if (fs != ss)
    {
        return false;
    }

    for (register int i=0; i < fs; i++) if (((f+i)*) != ((s+i)*))
    {
        return false;
    }

    return true;
}

Upvotes: 0

Related Questions