Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

i would try to use inpaint ( and not on the whole image, but only the border regions ):

void doInpaint(Mat &img) { // find black region: Mat gray; cvtColor(img,gray,COLOR_BGR2GRAY); Mat mask = gray == 0;

// get center color
Scalar m,s;
cv::meanStdDev(img, m, s, ~mask); // inverted mask !
// paint black area with center color,
// so we can use a smaller inpaint radius
img.setTo(m, mask);

inpaint(img,mask,img,30,INPAINT_TELEA);

}

void main() { int S = 30; Mat img = imread("stich_inp.png"); // top doInpaint(img(Rect(0,0,img.cols,S))); // bottom doInpaint(img(Rect(0,img.rows-S,img.cols,S))); // left doInpaint(img(Rect(0,0,S,img.rows))); // right doInpaint(img(Rect(img.cols-S,0,S,img.rows))); // imshow("final", img); imwrite("final.png", img); waitKey(); }

i would try to use inpaint ( and not on the whole image, but only the border regions ):

void doInpaint(Mat &img)
{
// find black region:
Mat gray; cvtColor(img,gray,COLOR_BGR2GRAY);
Mat mask = gray == 0;

// get center color
0;
// pre-fill black areas with mean color,
// for easier interpolation
Scalar m,s;
 cv::meanStdDev(img, m, s, ~mask); // inverted mask !
// paint black area with center color,
// so we can use a smaller inpaint radius
 img.setTo(m, mask);
 inpaint(img,mask,img,30,INPAINT_TELEA);

}

} void main() { int S = 30; Mat img = imread("stich_inp.png"); // top doInpaint(img(Rect(0,0,img.cols,S))); // bottom doInpaint(img(Rect(0,img.rows-S,img.cols,S))); // left doInpaint(img(Rect(0,0,S,img.rows))); // right doInpaint(img(Rect(img.cols-S,0,S,img.rows))); // imshow("final", img); imwrite("final.png", img); waitKey(); }}

image description

i would try to use inpaint

( and not on the whole image, but only the border regions ):

void doInpaint(Mat &img)
{
    // find black region:
    Mat gray; cvtColor(img,gray,COLOR_BGR2GRAY);
    Mat mask = gray == 0;

    // pre-fill  black areas with mean color,
    // for easier interpolation
    Scalar m,s;
    cv::meanStdDev(img, m, s, ~mask); // inverted mask !
    img.setTo(m, mask);

    inpaint(img,mask,img,30,INPAINT_TELEA);
}

void main()
{
    int S = 30;
    Mat img = imread("stich_inp.png");
    // top
    doInpaint(img(Rect(0,0,img.cols,S)));
    // bottom
    doInpaint(img(Rect(0,img.rows-S,img.cols,S)));
    // left
    doInpaint(img(Rect(0,0,S,img.rows)));
    // right
    doInpaint(img(Rect(img.cols-S,0,S,img.rows)));
    //
    imshow("final", img);
    imwrite("final.png", img);
    waitKey();
}

image description