tan and triggs illumination normalization

8
Tan and Triggs Illumination Normalization Pi19404 January 23, 2014

Upload: pi194043

Post on 22-Oct-2015

613 views

Category:

Documents


3 download

DESCRIPTION

This article describes the Tan and Triggs Illumination normalization procedure

TRANSCRIPT

Page 1: Tan and Triggs Illumination normalization

Tan and TriggsIlluminationNormalization

Pi19404

January 23, 2014

Page 2: Tan and Triggs Illumination normalization

Contents

Contents

Tan and Triggs Illumination Normalization 3

0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30.1.1 Illumination and Reflectance . . . . . . . . . . . . . . . . . . 30.1.2 Gamma Correction . . . . . . . . . . . . . . . . . . . . . . . . 40.1.3 Difference of Gaussian Filtering . . . . . . . . . . . . . . 50.1.4 Contrast Equalization . . . . . . . . . . . . . . . . . . . . . . 60.1.5 code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2 | 8

Page 3: Tan and Triggs Illumination normalization

Tan and Triggs Illumination Normalization

Tan and Triggs Illumination

Normalization

0.1 Introduction

In this article we will look at Tan and Triggs Illumination Normaliza-

tion method . The purpose is to preprocess images so as to make

them robust/invariant to illumination changes by employing a prepro-

cessing step.

� The present algorithm uses a series of step to counter the

effects of illumination variation,local shadowing and highlights.

� Preprocessing algorithms typicall introduce distortion in the im-

age,however the aim is to presever the disticntive features of

the image.

� The preprocessing chain consists of following steps : Gamma

Correction -> Difference of Gaussian Filtering ->Masking -

>Contrast Equalization

0.1.1 Illumination and Reflectance

� The intensity of light reflected from a object is production of

illumination and sufrace reflectance components f(x; y) = I(x; y)�R(x; y)

� Illumination I is ammount of light indident on the scene and is

dependent on external conditions.

� Reflectance is ammount of light reflected by the object,and

arises from property of object themselves.

� To compensate for non uniform illumination the aim is to re-

move the illumination component which is dependent on lighting

condition during image capture so that only reflectance compo-

nent that truly is a object property remains.

� Illumination varies slowly across the image as compared to re-

flectance.

3 | 8

Page 4: Tan and Triggs Illumination normalization

Tan and Triggs Illumination Normalization

� Illumination can be considered as low frequency,while reflectance

is a high frequency component present in the image.

� the product can be expressed as a sum by taking log log(I(x; y)) +log(R(x; y))

0.1.2 Gamma Correction

� Gamma Correction is a non linear gray level transformation

that replaces each pixel with intensity I in the image with I for

0 � � 1 or log(I) if = 0.

� Thus a gamma correction increases the dynamic range of the

image.

� The scale of the output image be from 0 to 255

� Gamma=1,is a identity transformation,where every pixel is mapped

to itself.

� Gamma=0.5 we can see that pixels from 0-50 are mapped to

larger range of 0-115 while pixels in the range 200-255 are

mapped to a smaller range of 230-255.

� Thus gamma correction has the effect of enhancing the dynamic

range of image in the dark regions while compressing it in the

bright regions.

� Therby improving the visibility can the contrast of the image.

Figure 1: Gamma Correction Curvers

Mat gammaCorrection(Mat image,float gamma)

{

Mat tmp;

image.convertTo(tmp, CV_32FC1,1.0/255.0,0);

pow(tmp, gamma, tmp);

tmp.convertTo(tmp,CV_8UC1,255.0,0);

return tmp;

}

4 | 8

Page 5: Tan and Triggs Illumination normalization

Tan and Triggs Illumination Normalization

� Increasing the gamma ,increases dynamic range in darker regions

while compresses it in the brighter regions further

Figure 2: Gamma Correction Images

0.1.3 Difference of Gaussian Filtering

Gamma correction or any other form of contrast normaliza-

tion algorithm does no remove the overall effects of intensity

gradients such as shading effects.

� Shading effects are considered to be predominantly low fre-

quency phenemenon.

� It is not possible to distinguish between a illumination gradient

and one caused by shading effects of surface structure Since

illumination is also modelled as low frequency phenomenon.

� A high pass filtering operations can be performed to remove

these components.

� DoG filter is a way to perform bandpass filtering operations

which remove shading and illumination components in the image

,and also reduces the noise.

� Dog Filter consists of 2

� DoG filter approximates a laplacian of gaussian filter,which is

used for edge detection

� The output of DoG Filter is a edge intensity image.

� Gaussians are charactesize by mean and variance/std deviation(sigma).

� A large sigma will blur out the fine details/edges while low pass

filtering, hence a small sigma is used which will only eliminate the

noise.

5 | 8

Page 6: Tan and Triggs Illumination normalization

Tan and Triggs Illumination Normalization

� The second gaussian has a large sigma,which removes high fre-

quency details in the image and retains only low frequency com-

ponents of the image .

� Now from we subtract this low frequency image from the

original low pass filtered image,therby obtaining a high fre-

quency edge image.

� Typically 1:2 ratio between the two gaussians provides good re-

sult. In present implementation the sigma is chosen as 3 and 7

for the gaussians

0.1.4 Contrast Equalization

� The final step of our preprocessing chain is contrast equaliza-

tion which globally rescales the image intensities to standardize

a robust measure of overall contrast or intensity varia- tion.

� Since DOG approximate gradient,there are bound to be extreme

value produced by highlights,shadows and noise etc

I =I

(mean(I�))1

alpha

(1)

I =I

(mean(min(�; I�)))1

alpha

(2)

I = � � tanh(I

�) (3)

(4)

� The output of above steps is a image with pixel intensity in the

ranges (��; �)

� To get a integer output ,we normalize the values between 0

to 255

Mat illumNorm(Mat image,float sigma0,float sigma1,

float alpha=0.1,float tau=10)

6 | 8

Page 7: Tan and Triggs Illumination normalization

Tan and Triggs Illumination Normalization

{

Mat tmp;

image.convertTo(tmp,CV_32FC1,1.0/255.0,0);

Mat gaussian0, gaussian1;

int kernel_sz0 = (sigma0);

int kernel_sz1 = (sigma1);

kernel_sz0 += ((kernel_sz0 % 2) == 0) ? 1 : 0;

kernel_sz1 += ((kernel_sz1 % 2) == 0) ? 1 : 0;

GaussianBlur(tmp, gaussian0, Size(kernel_sz0,kernel_sz0), sigma0, sigma0, BORDER_CONSTANT);

GaussianBlur(tmp, gaussian1, Size(kernel_sz1,kernel_sz1), sigma1, sigma1, BORDER_CONSTANT);

//difference of gaussian

cv::subtract(gaussian0,gaussian1,tmp);

Mat tmp1;

//contrast streching

double meanI = 0.0;

cv::pow(abs(tmp),alpha,tmp1);

meanI = mean(tmp1).val[0];

tmp = tmp / pow(meanI, 1.0f/alpha);

pow(min(abs(tmp), tau), alpha, tmp1);

meanI = mean(tmp1).val[0];

tmp = tmp / pow(meanI, 1.0f/alpha);

//tanh normalization

for(int r = 0; r < tmp.rows; r++) {

for(int c = 0; c < tmp.cols; c++) {

tmp.at<float>(r,c) = tanh(tmp.at<float>(r,c) / tau);

}

}

tmp = tau * tmp;

tmp=tmp+tau;

//integer value normalization

cv::normalize(tmp,tmp,0,255,CV_MINMAX);

tmp.convertTo(tmp,CV_8UC1,1.0,0);

return tmp;

}

7 | 8

Page 8: Tan and Triggs Illumination normalization

Tan and Triggs Illumination Normalization

0.1.5 code

� The code for this can be found in git repo /media/UBUNTU/repository/

OpenVisionLibrary/OpenVision in ImgProc/preprocess.hpp and Img-

Proc/preprocess.cpp files

8 | 8