Qt 5.3 下OpenCV 2.4.11 开发(5)最高效的像素引用
OpenCV 提供一个函数 getTickCount() ,能够用来測量一段代码的执行时间。另一个函数 getTickFrequency() 用来返回每秒内的时钟周期。代码操作例如以下:
double duration;
duration = static_cast<double>(getTickCount());
colorReduce(src);
duration = static_cast<double>(getTickCount()) - duration;
duration /= getTickFrequency();//执行时间以ms为单位
通过时间计算函数。对上小节中的像素引用方法做出对照。终于得出运算速度最快的 colorReduce() 函数。代码例如以下:
#include <QCoreApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp> using namespace cv; void colorReduce(Mat &source, int div = 64)
{
int row = source.rows;
int rowN = source.cols;
if ( source.isContinuous() )//检測图像内存是否连续
{
rowN = rowN * row;
row = 1;
} for ( int j = 0; j < row; j ++ )
{
uchar* data = source.ptr<uchar>(j);
for ( int i = 0; i < rowN; i ++ )
{
*data = *data/div*div + div/2;
data++;
*data = *data/div*div + div/2;
data++;
*data = *data/div*div + div/2;
data++;
}
}
} int main()
{
Mat src = imread("lena.jpg",1);
colorReduce(src);
namedWindow("src",0);
imshow("src",src);
waitKey(0);
return 0;
}
Qt 5.3 下OpenCV 2.4.11 开发(5)最高效的像素引用的更多相关文章
- Qt 5.3 下OpenCV 2.4.11 开发(0)图像处理基本概念
1.普通情况下的RGB彩色图像:它的每一个像素点都是由三个通道组成,即红色(R).绿色(G)和蓝色(B).8位三通道彩色图像就是每一个像素中每一个通道的取值范围都是 0~255(即二进制下的8位数), ...
- python 之django (一) Windows环境下Django 1.6.11开发环境搭建(简易版)
转自 https://www.cnblogs.com/kkddij/p/4397163.html 需要安装如下部件: python 2.6.6 pip(最新版即可) Django 1.6.11 PyC ...
- Qt 5.4 OpenCV 2.4.11 Win 32 Configuration
Download CMake 2.8.2 Download OpenCV 2.4.11 Download Qt 5.4 Highly improtant note: The installation ...
- 玩了下opencv的aruco(python版)
简单的玩了下opencv里头的aruco,用的手机相机,手机装了个 ip摄像头,这样视频就可以传到电脑上了. 首先是标定,我没打印chessboard,直接在电脑屏幕上显示,拍了17张,大概如下: 又 ...
- Python下opencv使用笔记(图像频域滤波与傅里叶变换)
Python下opencv使用笔记(图像频域滤波与傅里叶变换) 转载一只程序喵 最后发布于2018-04-06 19:07:26 阅读数 1654 收藏 展开 本文转载自 https://blog ...
- Qt creator中配置opencv win7 64bit
配置方法的原文来自https://www.librehat.com/qt-5-2-vs2012-opencv-2-4-7-dev-environment-setup-tutorial/. 补充,在张静 ...
- Android下OpenCV的环境搭建
目录(?)[-] 前言 系统环境 相关工具 Android ADT环境搭建 Android SDK环境变量的配置 Android NDK的安装与配置 OpenCV for Android 环境搭建 基 ...
- imread() not working in OpenCV 2.4.11 Debug mode
The OpenCV function imread() not working in OpenCV 2.4.11 Debug mode of VS2010 under Win32, the way ...
- Linux下安装mysql5.6.11(找点有用的信息太费劲)(转)
Linux下安装mysql5.6.11(找点有用的信息太费劲) (2013-04-25 10:25:09) 1.申请阿里云Linux服务器 昨天在阿里云申请了一个免费试用5天的Linux云服务 ...
随机推荐
- POJ——T2421 Constructing Roads
http://poj.org/problem?id=2421 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 24132 ...
- POJ 1281 MANAGER
MANAGER Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Description O ...
- Bootstrap全局CSS样式之表单
.form-control--将单独的表单控件赋予一些全局样式,如默认宽度width:100%. .form-group--包裹表单控件,获得最好的排列: .form-inline--将表单设置为内联 ...
- Matlab pchiptx
function v = pchiptx(x,y,u) %PCHIPTX Textbook piecewise cubic Hermite interpolation. % v = pchiptx(x ...
- UVALive 4222 /HDU 2961 Dance 大模拟
Dance Problem Description For a dance to be proper in the Altered Culture of Machinema, it must abid ...
- hpc-ai比赛相关资料
http://follitude.com/blog/Use-RDMA-Emulation-in-Software-Using-SoftiWARP/ https://www.reflectionsoft ...
- php 设计模式之观察者模式(订阅者模式)
php 设计模式之观察者模式 实例 没用设计模式的代码,这样的代码要是把最上面那部分也要符合要求加进来,就要修改代码,不符合宁增不改的原则 介绍 观察者模式定义对象的一对多依赖,这样一来,当一个对象改 ...
- Another app is currently holding the yum lock; waiting for it to exit…
yum被锁定无法使用,错误信息截图如下:解决方法:rm -rf /var/run/yum.pid 来强行解除锁定,然后你的yum就可以运行了
- VSCode向上的代码提示消除
VSCode虽然好用, 但是有些用户体验实在非常差, 比如这种往上面弹的类型提示... 在用户设置中增加: "editor.parameterHints": false
- Ubuntu新建用户并加入SUDO组
Ubuntu新建用户并加入SUDO组 新建用户: adduser xxxx 加入用户组: usermod -aG sudo username