# Absolute difference between images.

Hi,

I have two images that seem to be similar at a first sight. I have the following script that calculates the % difference of imgB - imgA. If the error is 0.0 then it calculates the % difference of imgA - imgB.

For this pair of images that seem similar the difference imgB - imgA gives 0.0 but the imgA - imgB gives 26%. How can I see what causes this difference?

How can I calculate the absolute difference of the two images?

## here is my code:

import numpy as np

from SimpleCV import Image

source*img = Image('44856.png')
target*img = Image('44856_target.png')

diff*img = target*img - source_img

matrix = diff_img.getNumpy()

flat = matrix.flatten()

num*change = np.count*nonzero(flat)

percent*change = 100 * float(num*change) / float(len(flat))

print percent_change

if percent*change == 0:
diff*img = source

*img - target*img

matrix = diff

*img.getNumpy()*

flat = matrix.flatten()

numchange = np.count

flat = matrix.flatten()

num

*nonzero(flat)*

percentchange = 100 * float(num_change) / float(len(flat))

percent

print percent*change
diff*filename = 'diff.png'

diff

*img.save(diff*filename)