Welcome. Also seehttp://imagemagick.org/script/compare.php
Is AE the metric you want? Are only regions of your image changing? Is the image format lossless? Is a slightly brightened image 100% different?
AE = absolute error count, number of different pixels (-fuzz effected)
Or do you have your method working, and you only need pointers on formatting the output?