How do one find the mean, std dev, and gradient from image integral? Given an image such as follows:
C+A-B-D
gives you the sum of the gray levels in the zone delimited by A,B,C,D, so, to get the mean you just need to dived it by the area of the zone:
mean = (C+A-B-D)/4
To get the dev, you must compute the sum of square area table (using cv::integral
you can pass a additional parameters to get the sum of squares). Quoting wikipedia, the standard deviation is equal to the square root of (the average of the squares less the square of the average). So assuming A',B',C',D' the values in your square area table:
dev = sqrt((C'+A'-B'-D')/4 - (mean*mean))
So computing mean and dev using integral image is very fast using integral images, especially if you want to compute those quantities at random locations and on random size of image patches.
Concerning the gradient, it's more complex. Are you sure you do not want to use sobel
operator?