Local Mean and Variance

asked 2018-06-08 10:34:08 -0500

updated 2018-06-08 10:42:50 -0500

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?

edit retag flag offensive close merge delete

Comments

Der Luftmensch gravatar imageDer Luftmensch ( 2018-06-08 10:38:11 -0500 )edit

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

Der Luftmensch gravatar imageDer Luftmensch ( 2018-06-08 11:48:33 -0500 )edit

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

LBerger gravatar imageLBerger ( 2018-06-08 14:24:41 -0500 )edit

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.

Tetragramm gravatar imageTetragramm ( 2018-06-08 15:46:19 -0500 )edit