// masktest.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
Mat image;
image = imread("1.jpg", IMREAD_COLOR); // Read the file
if (!image.data) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
// threshold to get mask
int threshold_value = 10;
int max_BINARY_value = 256;
Mat mask;
mask = imread("mask.jpg", 0);
// mask image
Mat img_masked;
image.copyTo(img_masked, mask);
imshow("image", image);
imshow("mask", mask);
imshow("img_masked", img_masked);
waitKey(0); // Wait for a keystroke in the window
return 0;
}