# Contrast Enhancement For An Image Using A Gaussian Function

I am working on a program that involves detecting faces in photos, i am reading a paper that someone has wrote and they said that they had more success detecting faces once he they applied some enhancements to the image, one of these being a contrast enhancement. The exact words are...

Contrast enhancement improves the overall quality of the image. Gaussian convolution using the Gaussian function G(x, y) is first applied with the input value channel image in the HSV space. The convolution process can be expressed as follows

They then give you Equation 3: $V_{con} = V_1(x,y) \oplus G(x,y)$ NOTE: $V_1$ is the original value

$V_{CON}$ in Eq. 3 denotes the convolution result, which contains the luminance information from the surrounding pixels. The center pixel value is now compared with the Gaussian convolution result in order to find the amount of contrast enhancement of that center pixel. This process is described by the following equation

Equation 4: $V_{ce}(x,y) = 255V_{le}(x,y)^{E(x,y)}$ NOTE: $V_{le}$ is the result of another enhancement done previously.

where $V_{CE}(x, y)$ is the result of contrast enhancement and $E(x, y)$ is given by the following relation

$E(x,y) = (V_{con}(x,y)/V_1(x,y))^g$

Here g is the image dependent parameter determined by using the standard deviation of the input value channel image. If the center pixel is brighter then the surrounding pixels, the contrast of the pixel is pulled up. On the other hand, if the center pixel is darker then the neighboring pixel then the contrast of the pixel is lowered.

The problem is that with my understanding of maths (NCEA Level 3, Last year at collage) i don't understand how to do the first part, any help would be much appreciated

The full paper is here: http://jips-k.org/dlibrary/JIPS_v09_no1_paper9.pdf

• Convolution (for which they are using "$\oplus$") just takes a weighted average of the pixels surrounding $x,y$. In the case of a gaussian convolution the weights are given by a gaussian distribution (the bell-shaped curve from probability). See en.wikipedia.org/wiki/Gaussian_filter. – Wandering Logic Jun 18 '13 at 11:52

Convolution is a relatively simple operation to perform, but to make it fast involves a little extra work (Wikipedia article on convolution theorem). In general, if you convolve a discretized function F by a different discretized function G, you are simply performing the following operation:

$$(F\otimes G)(x) = \displaystyle\sum_{i=0}^NF(x-i)*G(i)$$

Where N is the number of discrete values of G. Notice this is effectively just summing the product of F and G "centered" around $x$.

In 2D (which is what an image is), this looks like:

$$(F\otimes G)(x,y) = \displaystyle\sum_{i=0}^N\displaystyle\sum_{j=0}^MF(x-i,y-j)*G(i,j)$$

The paper you're reading tells you that F is the V channel of the image in HSV space, and G is a 2D gaussian function. Code-wise, the above form should translate very simply into a double-nested for loop.

The paper should also tell you what the mean/variance of the gaussian function is as well as the number of samples it contains, but sometimes that information is omitted.