OpenCV学习记录2

本文记录了使用OpenCV进行图像处理的学习过程,包括通过指针操作图像内容、获取图像通道数和尺寸、初始化空图像、计算处理时间以及调用filter2D函数的应用。
摘要由CSDN通过智能技术生成

一、学习内容

1. 通过指针,操作图像内容

uchar* output_row = output.ptr<uchar>(row);

output_row[col] = 5 * current_row[col] - (current_row[col-offset] + current_row[col + offset]+ previous_row[col]+ next_row[col]);

2. 获取图像的通道数、宽度cols、高度rows

    int offset = src.channels();
    int cols = src.cols * src.channels();//获取图像的实际总列数cols = 图像列数 * 图像通道数(例如,RGB图像的通道数是3)
    int rows = src.rows;

3. Mat 初始化一个空图像数据

Mat output = Mat::zeros(src.size(), src.type());

4. 计算用时

double t = getTickCount();//计算用时

double time_cost = (getTickCount() - t) / getTickFrequency();

5. 调用函数filter2D

filter2D(src, output, src.depth(), kernel);


二、代码调试

#include <opencv2/opencv.hpp>
#include <iostream>
#include <math.h>

using namespace cv;

int main(int argc, char** argv) {
	Mat src &#
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值