方法一:
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
}
}
方法二
for (int row = 0; row < mat->rows; row++){
const float* ptr = (cosnt float*) (mat->data.ptr + row * mat->step);
for (int col = 0; col < mat->cols; col++){
}
}
const float* ptr = (cosnt float*) (mat->data.ptr + row * mat->step);
for (int col = 0; col < mat->cols; col++){
}
}