Hi Everyone!! Have you ever been a victim of bad low light photography? Or does your phone not capture as good low light images as it claims? Have you ever thought of creating your own tool for low light photography? If your answers to all these questions is YES then scroll down and see what fix we have for you!

By the end of this article, you would be able achieve results like the below image.

Don’t stop! Keep scrolling and go through the blog in which I’ll guide you on how to create your own tool for low light image enhancement.


The trick I’ll be using to enhance low light images is to capture several low light photography shots of the object and then average it out.

How does it work? Well in low light your camera lens is not exposed to enough light and hence stores the noise in the pixels. If we take several (3-4) shots of the same image, and then average the pixels out, then the noise will be removed and you’ll get a clear picture.

It’s simple math πŸ˜‰ 

Importing Necessary Libraries

We will work with the following libraries:

  • cv2 – we need opencv for basic image loading, saving etc.
  • numpy – to do basic maths stuff here like taking average.
  • os – for navigating through directory
import cv2
import os
import numpy as np

Loading Images

We’ll start by accessing the folder where 3-4 shots of the images are stored. I’ll store the name of all the image files present in that folder in list variable β€˜files’.

path= os.getcwd()+ '/'+  'images'
files = list([os.path.join(path, f) for f in os.listdir(path)])

Now, I will store and load the first image in the variable ‘f‘. I’ll be initialising a variable β€˜cnt’ to keep a track of how many images have been elapsed/processed. Note that we’ll be reading images in float type as it will help us in taking average.

f= files[0]
image= cv2.imread(f).astype(np.float)

Next, we’ll loop through all the images present and store them in variable β€˜image’ along with incrementing variable β€˜cnt‘ upto 5 images.

for temp in files[1:]:
    temp_img= cv2.imread(temp)
    if cnt==5:

Now, I’ll take the average of the images by dividing it by β€˜cnt’. This is the special feature of numpy library that we can process the whole array/list with simplicity.

image = cv2.normalize(image, None, 0, 255, cv2.NORM_MINMAX)

At last, I’ll save the image and preview the before and after images. 

cv2.imwrite('output.png', image)


Wohoo Guys!! Finally you are having your own tool for low light photography. Now you can easily enhance the low light images and enjoy night photography. Cheers !!

If you liked the blog feel free to share it and please share your views in the comment section.

-Suniti Jain


Leave a Reply

Your email address will not be published. Required fields are marked *

Insert math as
Additional settings
Formula color
Text color
Type math using LaTeX
Nothing to preview