Friday, 2 August 2019

Comparing the Fitness of Two Images having the Same Size

This post provides a function which can compare two images, pixel by pixel, of the same size and return a measure between 0 and 1 indicating the fitness of the images.
  1. Python Image Library (PIL) will be called. This can be installed by:
    # apt-get install python-pil
  2. The two images for comparison should have the same dimensions.
  3. Pixel by pixel comparison is performed. For each pair of corresponding pixels from the two images, if their colours are different, even it is a small change, they are considered to be different.

Source Code




Test Images


p01.png

p01a.png

p02.png

p03.png
The original image Slightly different from p01.png The colour is different The colour and shape are different
Fitness: 1.0 Fitness: 0.993580246914 Fitness: 0.431604938272 Fitness: 0.31341563786

No comments:

Post a Comment