Wednesday, October 1, 2025
HomeLanguagesHow to Display Multiple Images in One Window using OpenCV Python?

How to Display Multiple Images in One Window using OpenCV Python?

Prerequisites: Opencv

In this article, we will show how to display Multiple Images In One window using OpenCV in Python.

Approach 

  • Import module
  • Load the Multiple images using cv2.imread()
  • Concatenate the images using concatenate(), with axis value provided as per orientation requirement
  • Display all the images using cv2.imshow()
  • Wait for keyboard button press using cv2.waitKey()
  • Exit window and destroy all windows using cv2.destroyAllWindows()

Functions Used

  • cv2.imread(): reads an image file from the given specific location
  • concatenate((image1,image2), axis): concatenates multiple images along a given mentioned axis (horizontal or vertical), The value of axis is given as 1 for combining them horizontally and 0 for combining them vertically.
  • cv2.imshow(): displays an image in a window
  • cv2.waitKey(): is a keyboard binding function. Its argument is the time in milliseconds. The function waits for specified milliseconds for any keyboard event.
  • cv2.destroyAllWindows(): If you have multiple windows open and you do not need those to be open, you can use cv2.destroyAllWindows() to close those all.

Program:

Python3




import cv2
import numpy as np
  
# Read First Image
img1 = cv2.imread('GFG.png')
  
# Read Second Image
img2 = cv2.imread('GFG.png')
  
  
# concatenate image Horizontally
Hori = np.concatenate((img1, img2), axis=1)
  
# concatenate image Vertically
Verti = np.concatenate((img1, img2), axis=0)
  
cv2.imshow('HORIZONTAL', Hori)
cv2.imshow('VERTICAL', Verti)
  
cv2.waitKey(0)
cv2.destroyAllWindows()


Input:

GFG.png

Output:

RELATED ARTICLES

Most Popular

Dominic
32330 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11926 POSTS0 COMMENTS
Shaida Kate Naidoo
6815 POSTS0 COMMENTS
Ted Musemwa
7078 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6774 POSTS0 COMMENTS