opencv2遍历图像程序
来源:互联网 发布:淘口令转换软件 编辑:程序博客网 时间:2024/04/28 22:10
(1)program_one
#include "cv.h"#include "highgui.h"#include "cxcore.h"#include <iostream>using namespace std;using namespace cv;void colorReduce(const Mat &Image, Mat &result, int div = 64);int main(void){Mat scr_Image = imread("F:\\1\\yellow_lane\\0.png", 1);//int div;//for(int j = 0; j<ScrImage.rows; j++)//{//uchar* data = ScrImage.ptr<uchar>(j);//for (int i = 0; i<(ScrImage.cols * ScrImage.channels()); i++)//{////data[i] = data[i]/div*div + div/2;////*data++ = *data/div*div + div/2;//uchar mask = 0xf0;//div = 16;//data[i] = (data[i] & mask) + div/2;//}//}Mat dst_Image;colorReduce(scr_Image, dst_Image);imshow("image", scr_Image);imshow("colorReduce", dst_Image);waitKey(0);return 0;}void colorReduce(const Mat &Image, Mat &result, int div){result.create(Image.rows, Image.cols, Image.type());int nr = Image.rows;int nc = Image.cols * Image.channels();for (int j = 0; j < nr; j++){const uchar* data_in = Image.ptr<uchar>(j);uchar* data_out = result.ptr<uchar>(j);for (int i = 0; i < nc; i++){data_out[i] = data_in[i]/div*div + div/2;}}}
(2) program_two
#include "cv.h"#include "highgui.h"#include "cxcore.h"#include <iostream>using namespace std;using namespace cv;void colorReduce(Mat &Image, int div = 64);int main(void){Mat scr_Image = imread("F:\\1\\yellow_lane\\0.png", 1);colorReduce(scr_Image);imshow("image", scr_Image);waitKey(0);return 0;}void colorReduce(Mat &Image, int div){int nr = Image.rows;int nc = Image.cols;if (Image.isContinuous())// 连续图像,没有额外的填补像素{nc = nc * nr;nr = 1;}for (int j = 0; j < nr; j++){uchar* data = Image.ptr<uchar>(j);for (int i = 0; i < nc; i++){data[i] = data[i]/div*div + div/2;}}}
(3) program_three
#include "cv.h"#include "highgui.h"#include "cxcore.h"#include <iostream>using namespace std;using namespace cv;void colorReduce(Mat &Image, int div = 64);int main(void){Mat scr_Image = imread("F:\\1\\yellow_lane\\0.png", 1);colorReduce(scr_Image);imshow("image", scr_Image);waitKey(0);return 0;}void colorReduce(Mat &Image, int div){if (Image.isContinuous())// 连续图像,没有额外的填补像素{Image.reshape(1, Image.cols * Image.rows);}int nr = Image.rows;int nc = Image.cols;for (int j = 0; j < nr; j++){uchar* data = Image.ptr<uchar>(j);for (int i = 0; i < nc; i++){data[i] = data[i]/div*div + div/2;}}}
0 0
- opencv2遍历图像程序
- OpenCv2(图像的遍历)
- [OpenCV2]使用指针遍历图像
- opencv2系列图像的遍历
- 【opencv2】:图像元素的遍历
- [OpenCV2]遍历图像的临近像素
- openCV2 第三讲 遍历图像1
- opencv2—(3)遍历图像
- 《opencv2》 遍历图像与邻域操作
- openCV2使用指针的方式遍历图像image.ptr
- Opencv2系列学习笔记2(图像的遍历)
- OPenCV2 如何使用指针的方式遍历图像
- opencv2中对图像ROI的理解及遍历操作
- OpenCV2 访问各个像素点的方法(图像遍历)
- Opencv2系列学习笔记2(图像的遍历)
- opencv2-遍历图像像素的14种方法
- opencv2—(4)遍历图像和邻域操作
- Opencv2系列学习笔记2(图像的遍历)
- css-01
- 使用PHP获取优酷网视频缩略图
- IOS 调用支付宝收不到支付回调
- IntelliJ Idea 常用快捷键列表
- PhpStorm 实用快捷键
- opencv2遍历图像程序
- 第九周项目三(矩阵转置)
- hdu3572 Task Schedule(Dinic判断是否满流)
- notepad++ 添加markdown插件
- Sicily DNA matching
- 文章标题
- route命令实用技巧
- 数组和list的互换
- Spring面试知识点总结