问题描述
我正在研究人脸识别项目.我的图片具有不同的照明,因此我需要进行照明归一化.我读了一篇声称进行照度归一化的论文.本文介绍了以下功能和值.
I am working on a face recognition project. I have pictures with different lighting so I need to do illumination normalization. I read a paper which which claims to do illumination normalization. The paper describe the following function and values.
1-使用gamma = 0.2的gamma校正
2-(sigma0 = 1,sigma1 = 2)的高斯(DOG)滤波的差
3-对比度均衡(本文使用截断阈值为10且压缩分量为0.1)
1- gamma correction with gamma = 0.2
2- Difference of Gaussian (DOG) filtering with (sigma0 = 1, sigma1 =2)
3- contrast equalization (truncation threshold of 10 and compressive component 0.1 is used in the paper)
我使用CvPow
进行伽玛校正,使用CvSmooth
进行DoG,使用Threshold()
进行截断(我不知道如何指定压缩分量),但是我没有得到确切的图像.我使用直方图均衡进行对比度均衡.
I use CvPow
for gamma correction, CvSmooth
for DoG and Threshold()
with truncate (I don't know how to specify the compression component) but I didn't get the exact image. I used histogram equalization for contrast equalization.
如果有人曾经做过或有任何想法?
If someone has done it before or has any idea??
论文链接: http://lear.inrialpes.fr /pubs/2007/TT07/Tan-amfg07a.pdf
下面的代码:(Peb Aryan的Python代码转换为JAVACV)
The code is below: (Python code of Peb Aryan converted to JAVACV)
public static IplImage preprocessImg(IplImage img)
{
IplImage gf = cvCreateImage(cvSize(img.width(),img.height()),IPL_DEPTH_32F, 1 );
IplImage gr = IplImage.create(img.width(),img.height(), IPL_DEPTH_8U, 1);
IplImage tr = IplImage.create(img.width(),img.height(), IPL_DEPTH_8U, 1);
IplImage b1 = IplImage.create(img.width(),img.height(),IPL_DEPTH_32F, 1 );
IplImage b2 = IplImage.create(img.width(),img.height(),IPL_DEPTH_32F, 1 );
IplImage b3 = IplImage.create(img.width(),img.height(),IPL_DEPTH_32F, 1 );
CvArr mask = IplImage.create(0,0,IPL_DEPTH_8U, 1 );
cvCvtColor(img, gr, CV_BGR2GRAY);
gamma(gr,gr,gf);
cvSmooth(gf,b1,CV_GAUSSIAN, 1);
cvSmooth(gf,b2,CV_GAUSSIAN,23);
cvSub(b1,b2,b2,mask);
cvConvertScale(b2,gr,127,127);
cvEqualizeHist(gr, gr);
//cvThreshold(gr,tr,255,0,CV_THRESH_TRUNC);
return gr;
}
public static void gamma(IplImage src,IplImage dst, IplImage temp)
{
cvConvertScale(src,temp, 1.0/255,0);
cvPow(temp, temp, 0.2);
cvConvertScale(temp, dst, 255,0);
}
这是我尝试的结果:
以及论文参考:
推荐答案
对您来说是否为时已晚.
Don't know if it's too late for you.
在原始论文中,DoG是由给定的sigma执行的,此处半径(23)太大.尝试radius = 7和radius =1.关于均衡步骤,它与纸张不同.您需要自己实施.
In the original paper, DoG was performed by a given sigma, here your radius(23) it too big. Try radius = 7 and radius = 1. About the equalization step, it's different from the paper. you need implement one by yourself.
顺便说一句:某些cvSmooth之类的基本功能未在您的应用程序中实现 right .您可能需要自己实施才能获得更好的结果.
BTW: some basic functions like cvSmooth was not implemented right for your application. You probably need to implement by yourself to get a better result.
这篇关于OpenCV中的照明标准化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!