Mat pic = imread(str, CV_LOAD_IMAGE_COLOR);
int channels=pic.channels();
int rows = pic.rows;
int cols = pic.cols;
for (int i = 0; i < rows; i++)//像素的遍历
{
for (int j=0; j < cols; j++)
{
pic.at<Vec3b>(i, j)[2]=0;//b通道
pic.at<Vec3b>(i, j)[0] = 0;//g通道
pic.at<Vec3b>(i, j)[1] = 0;//r通道
}
}