Skip to main content

Posts

Showing posts with the label Image Blending

Opencv Image Blending: How to blend two images?

Opencv Image Blending This process is very similar to image addition, but in this process images are given different weights. Thus, a transparent mixture is obtained. Images are added according to the following equation: 𝑔(π‘₯) = (1 − 𝛼)𝑓0(π‘₯) + 𝛼𝑓1(π‘₯) By changing the value of a between 0 and 1, transparency can be adjusted. In this study, 2 images were used to put them together. The weight was given 0.3 to the first picture and 0.7 to the second picture. cv2.addWeighted () applies the following equation to the image. 𝑑𝑠𝑑 = 𝛼 · π‘–π‘šπ‘”1 + 𝛽 · π‘–π‘šπ‘”2 + y Open images: image1 = cv2.imread( 'flower.jpg' ) image2 = cv2.imread( 'bird.jpg' ) Blending: rs = cv2.addWeighted(image1 , 0.3 , image2 , 0.7 , 0.0 ); Result: All Code: import cv2 image1 = cv2.imread( 'flower.jpg' ) image2 = cv2.imread( 'bird.jpg' ) image1 = cv2.resize(image1 , ( 300 , 300 )) image2 = cv2.resize(image2 , ( 300 , 300 )) rs = cv2.addWeighted(image1 , 0.3 , image2 , 0.7 , 0.0 ); cv...