你幾乎有
Mat white(768, 1024, CV_8UC3);
Mat red(100, 100, CV_8UC3);
Mat blue(100, 100, CV_8UC3);
white.setTo(Scalar(255, 255, 255));
red.setTo(Scalar(0, 0, 255));
blue.setTo(Scalar(255, 0, 0));
// this code places red image to the center square
red.copyTo(white(Rect(white.cols/2 - red.cols/2,
white.rows/2 - red.rows/2,
red.cols,
red.rows)));
// this code places blue image to the center circle
Mat circle_mask(blue.size(), CV_8UC1);
cv::circle(circle_mask, Point(circle_mask.cols/2, circle_mask.rows/2), 50, Scalar(255), CV_FILLED);
blue.copyTo(white(Rect(white.cols/2 - blue.cols/2,
white.rows/2 - blue.rows/2,
blue.cols,
blue.rows)), circle_mask);
cv::imshow("image", white);
waitKey(0);
第2行,笏是768和1024? – Steph
這是白色圖像的大小。 –
我想要做的是..輸入圖像,然後我創建的白色圖像需要輸入圖像的大小。可以這樣做嗎? – Steph