Computing image integral

前端 未结 3 1102
醉酒成梦
醉酒成梦 2021-02-03 12:39

How do one find the mean, std dev, and gradient from image integral? Given an image such as follows:

\"summed

3条回答
  •  时光取名叫无心
    2021-02-03 12:57

    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?

提交回复
热议问题