# Local Mean and Variance

I have an artificial flow field given by a homography transform. I want to compare this flow field to the results of an optical flow algorithm. I want to do a pixel-wise comparison in a statistical manner. It seems to me that I can best do this by comparing the optical flow value to the statistics of the local neighborhood of the homography flow. See this paper for inspiration.

My question is, what OpenCV functions can I use to calculate the local mean and variance over some window?

Stackoverflow

Bonus points for covariance. Rather than simply independent x and y variance.

What's problem ? you can apply same method for covariance (not in polar of course) : blur((x-blur(x)) (y-blur(y))

x-blur(x) can be done with separable dog filter

Yep, that stack overflow answer is correct.

You'd probably want to use the blur function, not the separable dog filter. blur uses a separable box filter with a O(1) cost, relative to the size of the box. Meaning an area 51x51 takes no longer than an area of 5x5.