标签:
// t1.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "iostream" #include "cv.h" #include "highgui.h" #include "opencv2/opencv.hpp" using namespace std; using namespace cv; int _tmain(int argc, _TCHAR* argv[]) { Mat grayim(600, 800, CV_8UC1); Mat colorim(600, 800, CV_8UC3); //遍历所有像素,并设置像素值 for ( int i = 0; i < grayim.rows; ++i ) for (int j = 0; j < grayim.cols; ++j) grayim.at<uchar>(i, j) - (i + j)%255; //遍历所有像素,并设置像素值 for ( int i = 0; i < colorim.rows; ++i) for ( int j = 0; j < colorim.cols; ++j) { Vec3b pixel; pixel[0] = i % 255; //blue pixel[1] = j % 255; //green pixel[2] = 0; //red colorim.at<Vec3b>(i, j) = pixel; } //显示结果 imshow("grayim", grayim); imshow("colorim", colorim); waitKey(0); return 0; }
标签:
原文地址:http://www.cnblogs.com/david-zhao/p/5074658.html