【opencv】遍历图片&Mask operation

本文介绍了如何在OpenCV中利用CV_EXPORTS_W void LUT函数遍历和处理图片,重点探讨了Mask操作在图像处理中的应用。
摘要由CSDN通过智能技术生成

遍历图片推荐使用CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst);

#include <opencv2\opencv.hpp>
#include <opencv2\core.hpp>

#include <iostream>

using namespace cv;
using namespace std;

Mat& ScanImageAndReduceC(Mat& I, const uchar* table);
Mat& ScanImageAndReduceIterator(Mat& I, const uchar* table);
Mat& ScanImageAndReduceRandomAccess(Mat& I, const uchar * table);

int ScanImg(int argc, char** argv)
{
	Mat image, outImage;
	image = imread("JayChou.jpg");
	if (image.empty()) {
		cout << "jpg couldn't to be load" << endl;
		return -1;
	}

	int divideWidth = 10;
	uchar table[256] = {0};
	for (int i = 0; i < 256; i++) {
		table[i] = (uchar)(divideWidth * (i / divideWidth));
	}

	const int times = 100;
	double t = 0;

	t = (double)getTickCount();
	for (int i = 0; i < times; i++) {
		Mat clone_i = image.clone();
		outImage = ScanImageAndReduceC(clone_i, table);
	}
	t = 1000*((double)getTickCount() - t) / getTickFrequency();
	t = t / times;
	cout << "Time of reducing with the C operator [] (averaged for "
         << times << " runs): " << t << " milliseconds."<< endl;

	t = (double)getTickCount();
	for (int i = 0; i < times; i++) {
		Mat clone_i = image.clone();
		outImage = ScanImageAndReduceIterator(clone_i, table);
	}
	t &#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值