opencvimage-processingmergeimage-editing

How to merge two image without losing intensity in opencv


I have two images in opencv: Image A and Image B.

Image A is output frame from camera.
Image B is alpha transparent image obtained by masking one image.
Before masking Image B it is warped with cvWarpPerspective()

Please help me out with something where I don't lose intensity in the output image after blending.

Thanks in advance


Solution

  • I finally got the answer.It consist of 5 steps....

    Step - 1

    cvGetPerspectiveTransform(q,pnt,warp_matrix); 
    //where pnt is four point x and y cordinates and warp_matrix is a 3 x 3 matrix
    

    Step - 2

    cvWarpPerspective(dst2, neg_img, warp_matrix,CV_INTER_LINEAR)
    //dst2 is overlay image ,neg_img is a blank image 
    

    Step - 3

    cvSmooth(neg_img,neg_img,CV_MEDIAN); //smoothing the image
    

    Step - 4

    cvThreshold(neg_img, cpy_img, 0, 255, CV_THRESH_BINARY_INV);
    //cpy_img is a created image from image_n
    

    Step - 5

    cvAnd(cpy_img,image_n,cpy_img);// image_n is a input image
    cvOr(neg_img,cpy_img,image_n);
    

    Output - image_n (without loosing intensity of input image)