reduce color
来源:互联网 发布:java教程中创建数据包 编辑:程序博客网 时间:2024/05/17 01:22
在看到Scanning an image with pointers中的减少图像中的色彩这个task时,对其中的原理不是很明白,现在想想主要是对被除数N的理解,当一维的像素点/N时,其实是代表取整,假设N为64,像素点为0到64,则64/N为0,表示的是在0到63之间都是0,同理在64到127之间为1,依此类推。。。
至于书上的像素点/N之后乘以N,其结果在加上N/2。表示的是取每段的中间值,即4个。原来表示的色彩为256*256*256,现在则为4*4*4.
时钟周期:如果cpu的时钟频率为8MHz,则时钟周期为:1/8MHz = 125 ns。
我的电脑为2.3GHz,则我的时钟周期为:1/2.3 = 0.43 ns
代码如下:
// a2.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <OpenCV245.h>using namespace std;using namespace cv;//void reduceColor(Mat &image, int N)//{//int ni = image.cols;//int nj = image.rows;//int np = image.cols * image.channels();//for (int j = 0; j < nj; j++)//{//uchar* data = image.ptr<uchar>(j);////for (int i = 0; i < np; i++)//{//data[i] = data[i]/N*N + N/2;//}//}//}void reduceColor(Mat &image, int div){int ni = image.cols;int nj = image.rows;for (int j = 0; j < nj; j++){for (int i = 0; i < ni; i++){image.at<Vec3b>(j, i)[0] = image.at<Vec3b>(j , i)[0]/div*div + div/2;image.at<Vec3b>(j, i)[1] = image.at<Vec3b>(j , i)[1]/div*div + div/2;image.at<Vec3b>(j, i)[2] = image.at<Vec3b>(j , i)[2]/div*div + div/2;}}}int _tmain(int argc, _TCHAR* argv[]){Mat img = imread("C:\\Users\\sony\\Desktop\\pic\\Lena.jpg");double duration = static_cast<double>(getTickCount());reduceColor(img, 64); duration = static_cast<double>(getTickCount()) - duration;cout<<"reduce time: "<<duration<<endl;imshow("dst", img);waitKey(0);return 0;}
- reduce color
- 一起学opencv2 (三) 扫描图像 COLOR REDUCE
- reduce
- reduce()
- reduce( )
- 【opencv学习之十六】像素操作和Reduce Color的例子
- color #
- color
- color
- Color
- color
- color
- color
- Color
- Color
- color
- COLOR
- Color
- C++ template笔记(备查)
- 【设计模式】学习笔记15:代理模式(Proxy Pattern)
- Hudson分布式构建
- C#程序运行时间的测试方法
- 利用Java反射机制改变SharedPreferences存储路径
- reduce color
- log4j 配置 整理一下
- tomcat部署web工程的两种方法(不用MyEclipse工具)
- 【原创分享】单片机菜单功能的设计(节点)----2009.07
- FFMpeg SDK 开发手册
- OSGi Lite for C++
- 图块分解
- 101条伟大的编程箴言
- FLEX项目打包war