OpenCV Python – Image Addition
Image addition is a basic but powerful operation in OpenCV used to combine two images or blend them together. It is widely used in image processing, computer vision, and multimedia applications.
In this tutorial, you will learn how to perform image addition and blending using OpenCV Python.
1. What is Image Addition?
Image addition means combining pixel values of two images.
It is used for:
- Image blending
- Overlay effects
- Double exposure effects
- Video frame merging
2. Import OpenCV and NumPy
import cv2
import numpy as np
3. Read Two Images
Both images must have the same size.
img1 = cv2.imread("image1.jpg")
img2 = cv2.imread("image2.jpg")
cv2.imshow("Image 1", img1)
cv2.imshow("Image 2", img2)
cv2.waitKey(0)
cv2.destroyAllWindows()
4. Simple Image Addition
Syntax:
cv2.add(image1, image2)
Example:
added = cv2.add(img1, img2)
cv2.imshow("Added Image", added)
cv2.waitKey(0)
cv2.destroyAllWindows()
5. Image Blending (Weighted Addition)
Weighted addition allows transparency control.
Syntax:
cv2.addWeighted(img1, alpha, img2, beta, gamma)
Example:
blended = cv2.addWeighted(img1, 0.7, img2, 0.3, 0)
cv2.imshow("Blended Image", blended)
cv2.waitKey(0)
cv2.destroyAllWindows()
6. Create Double Exposure Effect
blend = cv2.addWeighted(img1, 0.5, img2, 0.5, 0)
cv2.imshow("Double Exposure", blend)
cv2.waitKey(0)
cv2.destroyAllWindows()
7. Add Constant Value to Image
You can brighten an image by adding a constant.
bright = cv2.add(img1, np.ones(img1.shape, dtype=np.uint8) * 50)
cv2.imshow("Bright Image", bright)
cv2.waitKey(0)
cv2.destroyAllWindows()
8. Why Image Addition is Important
Image addition is used in:
- Photo editing apps
- Video blending
- AR/VR overlays
- Image enhancement
- Creative visual effects
9. Common Mistakes
❌ Images not same size
✔ Solution:
- Resize images before adding
img2 = cv2.resize(img2, (img1.shape[1], img1.shape[0]))
❌ Overflow issue (pixel clipping)
✔ Solution:
- Use cv2.add instead of + operator
10. Conclusion
Image addition in OpenCV Python is a simple but powerful technique for combining and blending images. It is widely used in image editing, creative effects, and computer vision applications.
Once you master image addition, you can move to advanced blending techniques like image pyramids and seamless cloning.


0 Comments