Skip to content

Instantly share code, notes, and snippets.

@rocking5566
Created April 9, 2018 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rocking5566/dbe24556f17c1cc44deab6b3f81fdf3d to your computer and use it in GitHub Desktop.
Save rocking5566/dbe24556f17c1cc44deab6b3f81fdf3d to your computer and use it in GitHub Desktop.
Poison Blending
#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