用掩模提高图像对比度
作者:互联网
tempel_copy = tempel_img.zeros(tempel_img.size(), tempel_img.type());
int offset = tempel_img.channels();//图像通道数
int rows = tempel_img.rows, cols = tempel_img.cols*offset;//列一定要乘以通道数
for (int r = 1; r < rows-1; r++)
{
uchar* last = tempel_img.ptr<uchar>(r - 1);//获取行指针
uchar* now = tempel_img.ptr<uchar>(r);
uchar* next = tempel_img.ptr<uchar>(r + 1);
uchar* dst_now = tempel_copy.ptr<uchar>(r);
for (int c = offset; c < cols - offset; c++)
dst_now[c] = saturate_cast<uchar>(5 * now[c] - (now[c - offset] + now[c + offset] + last[c] + next[c]));
}
imshow("copy",tempel_copy);
上述程序根据该计算方法实现对比度的增强
标签:tempel,img,int,offset,对比度,图像,掩模,now,ptr 来源: https://blog.csdn.net/weixin_43491924/article/details/90703264