OpenCV-Mat方式获取图片的像素(二)
来源:互联网 发布:百分百圣洁知乎 编辑:程序博客网 时间:2024/05/29 03:24
注意step是一个数组,随着维度会进行扩展,定义了矩阵的布局。
#include <iostream>#include <opencv2/opencv.hpp>#include <opencv2/highgui.hpp>using namespace std;using namespace cv;int main(int argc, const char * argv[]) { // insert code here... const char filename[] = "/Users/linwang/Downloads/Lena.jpg"; Mat Img = imread(filename); cout<<"三维图像的维度:"<<Img.dims<<endl; cout<<"三维图像的通道数:"<<Img.channels()<<endl; cout<<"三维图像的宽:"<<Img.rows<<endl; cout<<"三维图像的高:"<<Img.cols<<endl; cout<<"数据类型的大小 "<<Img.elemSize1()<<endl; cout<<"存放一个列元素的大小:"<<Img.elemSize()<<endl; cout<<" Img.step[0] = "<<Img.step[0]<<endl; cout<<" Img.step[1] = "<<Img.step[1]<<endl; Vec3i color; for (int row = 2;row<20;row++) { for(int col = 20;col<40;col++) { color[0] = int(*(Img.data + Img.step[0] * row + Img.step[1]* col)); color[1] = int(*(Img.data + Img.step[0] * row + Img.step[1]* col + Img.elemSize1()*1)); color[2] = int(*(Img.data + Img.step[0] * row + Img.step[1]* col + Img.elemSize1()*2)); cout<<color[0]<<"->"<<color[1]<<"->"<<color[2]<<endl; color[0] = 255; color[1] = 0; color[2] = 0; *(Img.data + Img.step[0] * row + Img.step[1]* col) = color[0]; *(Img.data + Img.step[0] * row + Img.step[1]* col + Img.elemSize1()*1) = color[1]; *(Img.data + Img.step[0] * row + Img.step[1]* col + Img.elemSize1()*2) = color[2]; } } imshow("test", Img); cvWaitKey(0); return 1;}
阅读全文
0 0
- OpenCV-Mat方式获取图片的像素(二)
- OpenCV-Mat方式的获取图片的像素(一)
- opencv 获取Mat像素值
- opencv像素的访问(Mat)
- 【OpenCV】访问Mat中每个像素的值(新)
- 【OpenCV】访问Mat中每个像素的值(新)
- 【OpenCV】访问Mat中每个像素的值(新)
- 【OpenCV】访问Mat中每个像素的值(新)
- 【OpenCV】访问Mat中每个像素的值(新)
- 【OpenCV】访问Mat中每个像素的值(新)
- 【OpenCV】访问Mat中每个像素的值(新)
- 【OpenCV】访问Mat中每个像素的值(新)
- OpenCV入门教程(2)-Mat类之像素的读写
- opencv访问(Mat)图像的像素方法汇总
- 【OpenCV】访问Mat中每个像素的值(新)
- Opencv中Mat对于像素的操作
- 【OpenCV】Mat对于像素的操作
- OPENCV使用Mat方式遍历图片的边界问题
- 二叉查找树的
- leetcode题解-58. Length of Last Word
- c:文本文件的读写(simple版)
- Python:读取Word的内容
- matlab fig另存为pdf 图片缺失解决方案
- OpenCV-Mat方式获取图片的像素(二)
- linux命令行的简单操作
- 你不知道的js(中卷)回调
- Java 面试题:百度前200页都在这里了
- java 图像灰度化
- golang使用protobuf
- 软件工程(C编码实践篇)学习总结
- 2017.11.13笔记
- 安装HADOOP伪分布式环境