Ask Your Question

Revision history [back]

I'm not sure but I think you can try something like this :

String nomFic = "c:/lib/opencv/samples/data/baboon.jpg";
Mat img1 = imread(nomFic, IMREAD_COLOR);
nomFic = "c:/lib/opencv/samples/data/lena.jpg";
Mat img2 = imread(nomFic, IMREAD_COLOR);
img1.convertTo(img1, CV_16SC3);
img2.convertTo(img2, CV_16SC3);
vector<Mat> x = { img1,img2 };
vector<UMat> ponderation;
vector<UMat> masque;
vector<Point> tl;
vector<Size> taille;

taille.push_back(img1.size());
taille.push_back(img2.size());
tl.push_back(Point(0, 0));
tl.push_back(Point(0, 0));
masque.push_back(UMat(img1.size(), CV_8UC1, Scalar(255)));
masque.push_back(UMat(img2.size(), CV_8UC1, Scalar(0)));
{
    Mat xtmp = masque[1].getMat(ACCESS_RW);
    circle(xtmp, Point(256, 256), 100,Scalar(255),-1);
}
Ptr<cv::detail::Blender> mixeurFeather2 = cv::detail::Blender::createDefault(cv::detail::Blender::FEATHER);
mixeurFeather2->prepare(tl, taille);
mixeurFeather2.dynamicCast<cv::detail::FeatherBlender>()->setSharpness(0.01);
for (int i = 0; i < x.size(); i++)
{
    mixeurFeather2->feed(x[i], masque[i], tl[i]);
}
mixeurFeather2.dynamicCast<cv::detail::FeatherBlender>()->createWeightMaps(masque, tl, ponderation);
{
    Mat xtmp = ponderation[0].getMat(ACCESS_RW);
    Rect r = Rect(220, 220, 72, 72);
    xtmp(r).setTo(1);
}

Then it is not finished but you have in ponderation[0] and ponderation[1] weighted maps for each image. You can modify and do your own blender algorithm... Unfortunately you cannot set new weighted map in FeatherBlender.