#include <stdio.h>
#include <cv.h>
#include <highgui.h>
void main(){
IplImage *img=cvLoadImage("c://fruitfs.bmp",1);
CvScalar s;
///////获取 像素值
for(int i=0;i<img->height;i++)...{
for(int j=0;j<img->width;j++)...{
s=cvGet2D(img,i,j); // get the (i,j) pixel value
printf("B=%f, G=%f, R=%f ",s.val[0],s.val[1],s.val[2]);
//////////////像素值改变赋值
s.val[0]=111;
s.val[1]=111;
s.val[2]=111;
cvSet2D(img,i,j,s);//set the (i,j) pixel value
}
}
cvNamedWindow("Image",1);
cvShowImage("Image",img);
cvWaitKey(0); //等待按键
cvDestroyWindow( "Image" );//销毁窗口
cvReleaseImage( &img ); //释放图像
return 0;
}