Created
          April 9, 2018 11:28 
        
      - 
      
- 
        Save rocking5566/dbe24556f17c1cc44deab6b3f81fdf3d to your computer and use it in GitHub Desktop. 
    Poison Blending
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <math.h> | |
| using namespace std; | |
| using namespace cv; | |
| cv::Mat GetMask(const Mat& img) | |
| { | |
| Mat ret; | |
| Mat imgGray; | |
| cvtColor(img, imgGray, CV_BGR2GRAY); | |
| threshold(imgGray, ret, 1, 255, THRESH_BINARY); | |
| medianBlur(ret, ret, 5); | |
| return ret; | |
| } | |
| void TestSeamlessBlending() | |
| { | |
| Mat patch = imread("patch.jpg"); | |
| Mat dst = imread("dst.jpg"); | |
| imshow("patch", patch); | |
| imshow("dst", dst); | |
| Mat patchMask = GetMask(patch); | |
| imshow("patchMask", patchMask); | |
| Mat blending; | |
| // TODO - Use landmark to warp | |
| Point center(dst.cols / 2, dst.rows / 2); | |
| seamlessClone(patch, dst, patchMask, center, blending, MIXED_CLONE); | |
| imshow("blending", blending); | |
| waitKey(0); | |
| } | |
| int main() | |
| { | |
| TestSeamlessBlending(); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment