mask operations
即,利用一个mask矩阵重新计算图像的每一个像素值,而这个mask矩阵调节相邻像素值对当前像素值的影响。我们利用图像对比度增强来说明,用下式来重新计算图像的像素值
我们通过自编函数与opencv提供的filter2D()函数来实现,一般情况下opencv自带的函数加入了优化,一般速度较快。
实现:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
void Sharpen(const Mat& Img,Mat& out)
{
CV_Assert(Img.depth() == CV_8U); // accept only uchar images
const int nChannels = Img.channels();
out.create(Img.size(),Img.type());
for(int j = 1 ; j < Img.rows-1; ++j)
{
const uchar* previous = Img.ptr<uchar>(j - 1);
const uchar* current = Img.ptr<uchar>(j