int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
char ch[] = { 'x', 'x', '.', 'j', 'p', 'g', '\0'};
std::string str = ch;
Mat mat1 = imread(str);
namedWindow("test1");
imshow("test1", mat1);
Mat mask = Mat::zeros(mat1.size(), CV_8U);
std::vector < std::vector<Point> > contours;
std::vector<Point> contour;
contour.push_back(Point(20, 220));
contour.push_back(Point(440, 220));
contour.push_back(Point(440, 440));
contour.push_back(Point(220, 440));
contours.push_back(contour);
drawContours(mask, contours, 0, CV_RGB(255, 255, 255), CV_FILLED, 8);
namedWindow("test");
imshow("test", mask);
{
char ch[] = { 'x', 'x', '.', 'j', 'p', 'g', '\0'};
std::string str = ch;
Mat mat1 = imread(str);
namedWindow("test1");
imshow("test1", mat1);
Mat mask = Mat::zeros(mat1.size(), CV_8U);
std::vector < std::vector<Point> > contours;
std::vector<Point> contour;
contour.push_back(Point(20, 220));
contour.push_back(Point(440, 220));
contour.push_back(Point(440, 440));
contour.push_back(Point(220, 440));
contours.push_back(contour);
drawContours(mask, contours, 0, CV_RGB(255, 255, 255), CV_FILLED, 8);
namedWindow("test");
imshow("test", mask);
Mat mat2 = Mat(mat1.size(), mat1.type());
mat1.copyTo(mat2, mask);
namedWindow("test2");
imshow("test2", mat2);
cv::waitKey(0);
return 0;
}
mat1.copyTo(mat2, mask);
namedWindow("test2");
imshow("test2", mat2);
cv::waitKey(0);
return 0;
}