Image Blending Using OpenCV Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report Image blending is used in computer vision that allows us to combine two or more images over each other. For example in Augmented Reality (AR) this technique is used by AR Glasses to blend virtual objects over our reality. It is also used in creating panoramas, creating special effects and Photography.Blending of Images Using OpenCVTo blend images using OpenCV, we will use weights over images to blend them. Here’s how we do it: Python import cv2 import matplotlib.pyplot as plt import requests from PIL import Image from io import BytesIO import numpy as np # Image URLs image1_url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRmKTFI_7r2TKR0sknfK_7GJX8sHItxbf-zh_jOJIBde2-L69K29IAzFLrD&s" image2_url = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQLVI5oqw867VkKFwDFtPaTGx2iRyLI2xth6m96yXdszR9vcfGi" response_image1 = requests.get(image1_url) response_image2 = requests.get(image2_url) img1 = Image.open(BytesIO(response_image1.content)) img2 = Image.open(BytesIO(response_image2.content)) image1 = cv2.cvtColor(np.array(img1), cv2.COLOR_RGB2BGR) image2 = cv2.cvtColor(np.array(img2), cv2.COLOR_RGB2BGR) image1 = cv2.resize(image1, (500, 500)) image2 = cv2.resize(image2, (500, 500)) # Set blending weights alpha = 0.5 beta = 0.5 blended_image = cv2.addWeighted(image1, alpha, image2, beta, 0) plt.figure(figsize=(15, 5)) plt.subplot(1, 3, 1) plt.imshow(cv2.cvtColor(image1, cv2.COLOR_BGR2RGB)) plt.title('Image 1') plt.axis('off') plt.subplot(1, 3, 2) plt.imshow(cv2.cvtColor(image2, cv2.COLOR_BGR2RGB)) plt.title('Image 2') plt.axis('off') plt.subplot(1, 3, 3) plt.imshow(cv2.cvtColor(blended_image, cv2.COLOR_BGR2RGB)) plt.title('Blended Image') plt.axis('off') plt.show() Output:Demonstration of Blended image Here Alpha and Beta refers to value (weights) for Image 1 and Image 2 respectfully. For above example, we have set the value of Alpha and Beta as 0.5.Now lets see how different value of Alpha and Beta affects Blended Image. Python import cv2 import matplotlib.pyplot as plt import requests from PIL import Image from io import BytesIO import numpy as np # Image URLs image1_url = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRmKTFI_7r2TKR0sknfK_7GJX8sHItxbf-zh_jOJIBde2-L69K29IAzFLrD&s" image2_url = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQLVI5oqw867VkKFwDFtPaTGx2iRyLI2xth6m96yXdszR9vcfGi" response_image1 = requests.get(image1_url) response_image2 = requests.get(image2_url) img1 = Image.open(BytesIO(response_image1.content)) img2 = Image.open(BytesIO(response_image2.content)) image1 = cv2.cvtColor(np.array(img1), cv2.COLOR_RGB2BGR) image2 = cv2.cvtColor(np.array(img2), cv2.COLOR_RGB2BGR) image1 = cv2.resize(image1, (500, 500)) image2 = cv2.resize(image2, (500, 500)) # Changing the values of alpha and beta alpha = 0.8 beta = 1-alpha # beta=0.2 blended_image = cv2.addWeighted(image1, alpha, image2, beta, 0) plt.figure(figsize=(15, 5)) plt.subplot(1, 3, 1) plt.imshow(cv2.cvtColor(image1, cv2.COLOR_BGR2RGB)) plt.title('Image 1') plt.axis('off') plt.subplot(1, 3, 2) plt.imshow(cv2.cvtColor(image2, cv2.COLOR_BGR2RGB)) plt.title('Image 2') plt.axis('off') plt.subplot(1, 3, 3) plt.imshow(cv2.cvtColor(blended_image, cv2.COLOR_BGR2RGB)) plt.title('Blended Image') plt.axis('off') plt.show() Output:Changing the blended image due to change of values of alpha and beta Now when we increased weights of Image 1 i.e Alpha value to 0.8 we can see prominence of Image 1 in Blended Image. Weights of Alpha and Beta combined should not exceed 1.Image blending with OpenCV is a easy to use technique used in Computer Vision. By experimenting with different weights and images, we can achieve different results. Comment S sahilgupta03 Follow 1 Improve S sahilgupta03 Follow 1 Improve Article Tags : Computer Vision AI-ML-DS Python-OpenCV AI-ML-DS With Python Explore Introduction to Computer VisionComputer Vision - Introduction 4 min read A Quick Overview to Computer Vision 3 min read Applications of Computer Vision 6 min read Fundamentals of Image Formation 7 min read Satellite Image Processing 2 min read Image Formats 5 min read Image Processing & TransformationDigital Image Processing Basics 7 min read Difference Between RGB, CMYK, HSV, and YIQ Color Models 3 min read Image Enhancement Techniques using OpenCV - Python 15+ min read Image Transformations using OpenCV in Python 5 min read How to find the Fourier Transform of an image using OpenCV Python? 5 min read Python | Intensity Transformation Operations on Images 5 min read Histogram Equalization in Digital Image Processing 5 min read Python - Color Inversion using Pillow 4 min read Image Sharpening using Laplacian, High Boost Filtering in MATLAB 3 min read Wand sharpen() function - Python 2 min read Python OpenCV - Smoothing and Blurring 7 min read Python PIL | GaussianBlur() method 1 min read Apply a Gauss filter to an image with Python 2 min read Spatial Filtering and its Types 3 min read Python PIL | MedianFilter() and ModeFilter() method 1 min read Python | Bilateral Filtering 2 min read Python OpenCV - Morphological Operations 5 min read Erosion and Dilation of images using OpenCV in Python 3 min read Introduction to Resampling methods 8 min read Python | Image Registration using OpenCV 3 min read Feature Extraction and DescriptionFeature Extraction Techniques - NLP 10 min read SIFT Interest Point Detector Using Python - OpenCV 4 min read Feature Matching using Brute Force in OpenCV 13 min read Feature detection and matching with OpenCV-Python 5 min read Feature matching using ORB algorithm in Python-OpenCV 3 min read Mahotas - Speeded-Up Robust Features 2 min read Create Local Binary Pattern of an image using OpenCV-Python 5 min read Deep Learning for Computer VisionImage Classification using CNN 5 min read What is Transfer Learning? 8 min read Top 5 PreTrained Models in Natural Language Processing (NLP) 7 min read ML | Introduction to Strided Convolutions 2 min read Dilated Convolution 5 min read Continuous Kernel Convolution 6 min read CNN | Introduction to Pooling Layer 5 min read CNN | Introduction to Padding 5 min read What is the difference between 'SAME' and 'VALID' padding in tf.nn.max_pool of tensorflow? 14 min read Convolutional Neural Network (CNN) Architectures 11 min read Deep Transfer Learning - Introduction 8 min read Introduction to Residual Networks 4 min read Residual Networks (ResNet) - Deep Learning 9 min read ML | Inception Network V1 4 min read Understanding GoogLeNet Model - CNN Architecture 3 min read Image Recognition with Mobilenet 4 min read VGG-16 | CNN model 6 min read Autoencoders in Machine Learning 7 min read How Autoencoders works ? 6 min read Difference Between Encoder and Decoder 9 min read Implementing an Autoencoder in PyTorch 4 min read Generative Adversarial Network (GAN) 11 min read Deep Convolutional GAN with Keras 9 min read StyleGAN - Style Generative Adversarial Networks 5 min read Object Detection and RecognitionDetect an object with OpenCV-Python 4 min read Haar Cascades for Object Detection - Python 3 min read R-CNN - Region-Based Convolutional Neural Networks 8 min read YOLO v2 - Object Detection 7 min read Face recognition using Artificial Intelligence 15+ min read Deep Face Recognition 8 min read ML | Face Recognition Using Eigenfaces (PCA Algorithm) 4 min read Emojify using Face Recognition with Machine Learning 7 min read Object Detection with Detection Transformer (DETR) by Facebook 7 min read Image SegmentationImage Segmentation Using TensorFlow 5 min read Thresholding-Based Image Segmentation 7 min read Region and Edge Based Segmentation 4 min read Image Segmentation with Watershed Algorithm - OpenCV Python 9 min read Mask R-CNN | ML 9 min read 3D ReconstructionPython OpenCV - Depth map from Stereo Images 2 min read Top 7 Modern-Day Applications of Augmented Reality (AR) 10 min read Virtual Reality, Augmented Reality, and Mixed Reality 3 min read Camera Calibration with Python - OpenCV 4 min read Python OpenCV - Pose Estimation 7 min read 40+ Top Computer Vision Projects [2025 Updated] 4 min read Like