opencv3.0访问像图像的像素值并显示

来源:互联网 发布:php xss 编辑:程序博客网 时间:2024/05/20 13:07
#include <opencv2/core/core.hpp>  #include <opencv2/highgui/highgui.hpp>  #include <iostream>  using namespace std;using namespace cv;int main(){//【1】创建原始图并显示Mat srcImage = imread("D:\\pictures\\lena.jpg",0);int width = srcImage.rows;int height = srcImage.cols;cout << "width=" << width<< endl << "hight=" << height << endl;uchar* ptr = srcImage.data;for (int row = 0; row<height; row++){uchar* data = srcImage.ptr<uchar>(row);//获得灰度值数据指针  for (int cols = 0; cols<width; cols++){int intensity = ptr[cols];cout <<(int) intensity << "  ";}}system("pause");return 0;}

运行结果:


阅读全文
0 0
原创粉丝点击