In this article, we will show how to display Multiple Images In One window using OpenCV in Python.
- 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()
- 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.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.