作为OpenCV基础知识中的重中之重,像素值的读写需要我们很用心的掌握。
1、读取原图
const char filename[] = "/Users/linwang/Desktop/Lena.png";
Mat Im = imread(filename);
cout<<"Im.dims = "<<Im.dims<<endl;
cout<<"Im.rows = "<<Im.rows<<endl;
cout<<"Im.cols = "<<Im.cols<<endl;
cout<<"Im.channels = "<<Im.channels()<<endl;
cout<<"Im.step[0] = " <<Im.step[0]<<endl;
cout<<"Im.step[1] = " <<Im.step[1]<<endl;
cout<<"Im.Elemsize = "<<Im.elemSize()<<endl; //一个像素点的大小 CV_8U3C=1*3
cout<<"Im.Elemsize1 = "<<Im.elemSize1()<<endl; //数据类型的大小 UCHAR = 1 (ElemSize / Channel)
namedWindow("Old-Lena");
imshow("Old-Lena", Im);</