您的位置:首页 > 运维架构

OpenCV例程2 how to scan images

2013-08-23 17:19 190 查看
This program shows how to scan image obiects in OpenCV(CV::Mat).

we take an inout image and divide the native color palette(255) with the input. Show C operator[] method, itertors and at function for on-the-fly item address calculation.

The example as follows:

int main()

{

help();

Mat img=imread("lena.jpg");

if(img.empty())

{

cout<<"There is no picture."<<endl;

return -1;

}

int nRows=img.rows;

int nCols=img.cols*img.channels();

int i,j;

uchar* p;

int N=100;

for(i=0;i<nRows;i++)

{

uchar* p=img.ptr<uchar>(i);

for(j=0;j<nCols;j++)

{

p[j]=p[j]/N*N;

}

}

namedWindow("image",1);

imshow("image",img);

waitKey();

return 0;

}

需要理解圖像怎麼存儲的,再去理解怎麼scan的。

run:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: