level 1
阿Q盗版
楼主
main函数
int main()
{
Mat image;
image = imread("1.jpg",0);//如果把这里的0去掉,程序可以运行,有会报错
cout << "ok" << endl;
colorReduce11(image);
cvNamedWindow("window",WINDOW_NORMAL);
imshow("window", image);
waitKey(0);
return 0;
}
//colorReduce11
void colorReduce11(cv::Mat &image, int div = 64) {
int nr = image.rows; // number of rows
int nc = image.cols; // number of columns
for (int j = 0; j<nr; j++) {
for (int i = 0; i<nc; i++) {
image.at<cv::Vec3b>(j, i)[0] = image.at<cv::Vec3b>(j, i)[0] / div*div + div / 2;
} // end of row
}
}
2015年03月22日 02点03分
1
int main()
{
Mat image;
image = imread("1.jpg",0);//如果把这里的0去掉,程序可以运行,有会报错
cout << "ok" << endl;
colorReduce11(image);
cvNamedWindow("window",WINDOW_NORMAL);
imshow("window", image);
waitKey(0);
return 0;
}
//colorReduce11
void colorReduce11(cv::Mat &image, int div = 64) {
int nr = image.rows; // number of rows
int nc = image.cols; // number of columns
for (int j = 0; j<nr; j++) {
for (int i = 0; i<nc; i++) {
image.at<cv::Vec3b>(j, i)[0] = image.at<cv::Vec3b>(j, i)[0] / div*div + div / 2;
} // end of row
}
}