How to combine two images without loss of intensity in opencv

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

Image A is the output frame from the camera.
Image B is an alpha-transparent image obtained by masking a single image.
Before masking Image B, it is distorted withcvWarpPerspective()

  • I tried cvAddWeighted() - It loses intensity when you give alpha and beta value
  • I tried aishack - Even here you lose the overall intensity of the output image
  • I tried silveiraneto.net - Not useful in my case

Please help me with something where I do not lose intensity in the output image after mixing.

Thanks in advance

+5
source share
2 answers

I finally got a response. It consists 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 loss of input image intensity)

+2
source

When you say that you are losing intensity ... you leave the question of how you lose it?

You are losing intensity in the sense of:

That when you add images, you reach maximum intensity, and the rest are discarded. (Example for adding an 8-bit pixel: Pix1 = 200 i, Pix2 = 150 i. "Pix1 + Pix2 = 350", but the maximum value is 255, so Pix1 + Pix2 = 255)

A , Image B, . ( 8- : Pix1 = 200 i, Pix2 = 150, (Pix1 + Pix2)/2 = 175, , Pix2 = 0. (Pix1 + Pix2 )/2 = 100, )

, . , , .

+2

All Articles