#掩膜
实现图像对比度提高
##通过指针访问数据
row:行
col:列
RGB为三通道(channel)
ptr:指针
zero(0):代表0~255中的0,黑色
saturate_cast:像素处理范围保证在0~255
读一张图像(src)
int cols =(src.cols-1)*src.channels();
int rows =src.rows;
int offsetx=src.channels;
dst=Mat::zeros(src.size(),src.type());
for(int row=1;row<(rows-1);row++){
const uchar current=src.ptr(row);
const ucharprevious=src.ptr(row-1);
const ucharnext=src.ptr(row+1);
ucharoutput=dst,ptr(row);
for(int col=offsetx;col<cols;col++){
output[col]=saturate_cast5*current[col]-(current[col-offsetx]+current[col+offsetx]+previous[col]+next[col]);
}
}
##函数调用方法
函数调用filter2D功能
定义掩膜 Mat kernel=(Mat_(3,3)<<0,-1,0,-1,5,-1,0,-1,0);
filter2D(src,dst,src.depth(),kernel);
其中src.depth()可用-1代替