Page 1 of 1

Compute variance between two images

Posted: 2010-09-01T20:24:31-07:00
by hwttdz
I'd like to make a sort of fuzzy compare between two images (A and B, with dimensions x,y). In order to do this I'd like to compute the variance between the two images where

variance = sum over (x,y) { [red(A(x,y))-red(B(x,y))]^2+[green(A(x,y))-green(B(x,y))]^2+[blue(A(x,y))-green(B(x,y))]^2 }/(x*y)

I think there must be a reasonably quick way to do this but thus far the best I've come up with is to output both A and B as text files and then go to work on it with an external program.

Re: Compute variance between two images

Posted: 2010-09-03T14:26:01-07:00
by fmw42
compare -metric rmse image1 image2 null:


gives you the square root of the mean squared error, which is similar to what you are asking (barring the square root). So perhaps you can take that result and use some -fx calculation to square it to get close to your variance.

see compare statistics at http://www.imagemagick.org/Usage/compare/#compare

Re: Compute variance between two images

Posted: 2010-09-05T23:34:25-07:00
by anthony
the 'mse' (mean square error) is the same as 'rmse' just does not do the final square root.

See Compare Statistics (raw notes)
http://www.imagemagick.org/Usage/compare/#statistics