In this blog, we will learn how simple arithmetic operations like addition, subtraction etc can be used for image enhancement. First, let’s start with image addition also known as Image
This is based on the assumption that noise present in the image is purely random(uncorrelated) and thus has zero average value. So, if we average n noisy images of
Applicability Conditions: Images should be taken under identical conditions with same camera settings like in the field of astronomy.
Advantages: Reduce noise without compromising image details unlike most other operations like filtering.
Disadvantages: Increases time and storage as now one needs to take multiple photos of the same object. Only applicable for random noise. Must follow the above applicability condition.
Below is the code where first I generated 20 images by adding random noise to the original image and then average these images to get the approx. original image.
cv2.randn(image, mean, standard deviation) fills the image with normally distributed random numbers with specified mean and standard deviation.
import numpy as np
# Load original image
img = cv2.imread('D:/downloads/forest.jpg')
# Create list to store noisy images
images = 
# Generate noisy images using cv2.randn. Can use your own mean and std.
for _ in range(20):
img1 = img.copy()
# For averaging create an empty array, then add images to this array.
for im in images:
# Round the float values. Always specify the dtype
# Display the images
This is mainly used to enhance the difference between images. Used for background subtraction for detecting moving objects, in medical science for detecting blockage in the veins etc a field known as mask mode radiography. In this, we take 2 images, one before injecting a contrast medium and other after injecting. Then we subtract these 2 images to know how that medium propagated, is there any blockage or not.
This can be used to extract Region of interest (ROI) from an image. We simply create a mask and multiply the image with the mask to get the area of interest. Other applications can be shading correction which we will discuss in detail in the next blogs.
In the next blog, we will discuss intensity transformation, a spatial domain image enhancement technique. Hope you enjoy reading.
If you have any doubt/suggestion please feel free to ask and I will do my best to help or improve myself. Good-bye until next time.