Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi sturkmen,

thank you very much for the nice code!

No just the background of the normal seamlessClone is missing.

This can be achieved by increasing the brightness and then blurring.

I just added this code before the logo.copyTo:

    double alpha=1.0; //alpha value [1.0-3.0]
    int beta=70; //beta value [0-100]

    /// Increasing brightness:
    /// Do the operation image(i,j) = alpha*image(i,j) + beta
     for( int y2 = y; y2 < mask.rows+100; y2++ )
        {
         for( int x2 = x; x2 < mask.cols+100; x2++ )
             {
                for( int c = 0; c < 3; c++ )
                  {
                    frame.at<Vec3b>(y2,x2)[c] =
                    saturate_cast<uchar>( alpha*( frame.at<Vec3b>(y2,x2)[c] ) + beta );
                  }
             }
        }
    cv::Rect region (x,y,logo.cols, logo.rows);

    ///Blurring:
    GaussianBlur(frame(region), frame(region), Size(0, 0), 6);


    logo.copyTo(frame(region),mask);

There is just one thing I do not know how to manage. As you can see I used manual values in the first two for loops (mask.rows+100). I do not know where to get the real dimensions of the logo automatically as it is copied using a mask.

Still... the solution works now quite nice :-) Thanks a lot!

Hi sturkmen,

thank you very much for the nice code!

No just the background of the normal seamlessClone is missing.

This can be achieved by increasing the brightness and then blurring.

I just added this code before the logo.copyTo:

    double alpha=1.0; //alpha value [1.0-3.0]
    int beta=70; //beta value [0-100]

    /// Increasing brightness:
    /// Do the operation image(i,j) = alpha*image(i,j) + beta
     for( int y2 = y; y2 < mask.rows+100; mask.rows+y; y2++ )
        {
         for( int x2 = x; x2 < mask.cols+100; mask.cols+x; x2++ )
             {
                for( int c = 0; c < 3; c++ )
                  {
                    frame.at<Vec3b>(y2,x2)[c] =
                    saturate_cast<uchar>( alpha*( frame.at<Vec3b>(y2,x2)[c] ) + beta );
                  }
             }
        }
    cv::Rect region (x,y,logo.cols, logo.rows);

    ///Blurring:
    GaussianBlur(frame(region), frame(region), Size(0, 0), 6);


    logo.copyTo(frame(region),mask);

There is just one thing I do not know how to manage. As you can see I used manual values in the first two for loops (mask.rows+100). I do not know where to get the real dimensions of the logo automatically as it is copied using a mask.

Still... the solution works now quite nice :-) Thanks a lot!