Simon Canning
Simon Canning

Reputation: 215

Comparing two images visually

I am wanting to be able to check to see if two images appear to be the same, within a certain threshold.

Image 1

Image 2

These two images are the same to the eye, but one has slightly different colors. I have tried the following example:

http://www.vb-helper.com/howto_net_image_compare_threshold.html

Unfortunately, it only seems to detect when the images are identical. How can I determine if the images are the same within a certain threshold, with VB.NET?

Upvotes: 3

Views: 1455

Answers (2)

endolith
endolith

Reputation: 26843

  • Divide image into R, G, B
  • For each color:
    • For each (x, y):
      • Multiply the pixel of Image 1 with the pixel of Image 2
    • Sum all the pixel values
  • Sum the 3 values for each color

This is the correlation between the two images. To get a value from 0 to 1, first calculate the correlation of an image with itself to see what the best possible value is, then do the correlation of Image 1 with Image 2 and divide by the best possible value.

Upvotes: 0

xpda
xpda

Reputation: 15813

  1. Resize both images to the same, small size, such as 16x12 or 90x60 (depending on your threshold).
  2. Reduce the color depth to 4 or 8 bits per pixel (not palettized). You might use a posterize function for this.

Then then see if the two smaller images are duplicates. If so, the originals must be pretty close.

Upvotes: 4

Related Questions