Monday 10 March 2014

Integral Images for computing Mean and Variance

Integral Images for computing Mean and Variance

Introduction

  • The Integral Image is used as a quick and effective way of calculating the sum of values (pixel values) in a given image รข€“ or a rectangular subset of a grid (the given image).
  • In this article we will assume that concepts of integral image is known and then proceed to see how it can be used to compute the mean and variance of a image patch.
  • Given a integral representation of an image,the sum of value of pixels in the rectangular region R with vertices A,B,C,D is given by \[ I = S(A) +S(D) -S(B) -S(C) \]
  • Dividing this quantity by the number of pixels gives us the mean value of pixels in the region. \[ \mu = \frac{I}{N} \]
  • Let us also consider the squared integral image.To obtain this all the pixel values in the image are squared then integral image is computed.
  • consider the variance about a rectangulation regions \[ v= \sum_i (x_i-\mu)^2 v= \sum_i x_i^2 - 2\sum_i x_i \mu + \mu^2 v= \sum_i x_i^2 - \mu^2 \] The summation $x_i^2$ can obtained by the square integral image and $\mu$ can be obtained by integral image computation.
  • This enables us to compute the variance of rectangular patch of image.
  • A similar method can be employed to compute the denominator variance term normalize cross correlation formula.
  • the above code can be found in git repo https://github.com/pi19404/OpenVision/tree/master/ ImgFeatures/integralImage.cpp and ImgFeatures/integralImage.hpp files.

No comments:

Post a Comment