How can I calculate the Mean Square Error (MSE) of two RGB images (having 3 channels)? I am using the Opencv Library and it does not appear to have a function for this. Is there any formula? Please help..
Printable View
How can I calculate the Mean Square Error (MSE) of two RGB images (having 3 channels)? I am using the Opencv Library and it does not appear to have a function for this. Is there any formula? Please help..
Are you assuming they're aligned, or are you using the MSE to try and align them? (There are better ways to align images, but MSE is a conceptually simple one.)
If the former, then pseudocode would be:
Using OpenCV, this may actually be easier if you convert your IplImage into a CvMat, because finding the squared difference of two matrices is very straightforward, as is accumulating an array. But the problem is trivial enough that a simple series of loops is probably about the same amount of code.Code:FOR every pixel
FOR every channel
ACCUMULATE the square difference in pixel channel intensity
DIVIDE by the number of pixels*channels