标签:src 掩膜 int current OpenCV 图像 row col Mat
程序代码
#include <opencv2/opencv.hpp>
#include <iostream>
#include <opencv2/core/utils/logger.hpp>
using namespace std;
using namespace cv;
int main(int argc, const char** argv)
{
setLogLevel(utils::logging::LOG_LEVEL_SILENT); //设置日志输出
Mat src = imread("E:/picture/9.jpg");
Mat dst = Mat::zeros(src.size(), src.type());
if (src.empty())
{
cout << "could not find picture" << endl;
return -1;
}
//int cols = (src.cols - 1) * src.channels();
//int rows = src.rows;
//int offsetx = src.channels();
//for (int row = 1; row < (rows - 1); row++)
//{
// const uchar* previous = src.ptr<uchar>(row - 1);
// const uchar* current = src.ptr<uchar>(row);
// const uchar* next = src.ptr<uchar>(row + 1);
// uchar* output = dst.ptr<uchar>(row);
// for (int col = offsetx; col < cols; col++)
// {
// output[col] = saturate_cast<uchar>(5 * current[col] - (current[col] - offsetx + current[col + offsetx]
// + previous[col] + next[col]));
// }
//}
double t1 = getTickCount();
Mat kernel = (Mat_<char>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
filter2D(src, dst, src.depth(), kernel);
imshow("input", src);
imshow("output", dst);
double t2 = (getTickCount() - t1) / getTickFrequency();
cout << "Time=" << t2 << "\n";
waitKey(0);
destroyAllWindows();
return 0;
}
执行结果:
标签:src,掩膜,int,current,OpenCV,图像,row,col,Mat 来源: https://blog.csdn.net/qq_51890340/article/details/122761388
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。