标签:图像处理
对数变换可实现图像的水平平移、竖直平移、对称变换等操作
也可实现图像灰度的扩展和压缩功能。
实现代码如下:
</pre><pre name="code" class="cpp">int LogTranslation(Mat srcImg, Mat dstImg, float a, float b, float c)
{
Mat logTable(1,256,CV_8U);
double temp;
for ( int i = 0; i < 256; i++ )
{
temp = log((double)i+1)/b + a; //对数变换 g(x,y) = ln(f(x,y)+1)/(b*ln(c)) + a;
if (temp < 0.0)
{
temp = 0.0;
}
else if (temp > 255.0)
{
temp = 255.0;
}
logTable.data[i] = int(temp + 0.5); //四舍五入
}
LUT(srcImg,logTable,dstImg);
imshow("Log", dstImg);
waitKey(0);
return 1;
}标签:图像处理
原文地址:http://blog.csdn.net/xiao_lxl/article/details/45560843