opencv随笔(二)

#掩膜
实现图像对比度提高
在这里插入图片描述
##通过指针访问数据
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 uchar
previous=src.ptr(row-1);
const ucharnext=src.ptr(row+1);
uchar
output=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代替

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值