Combine 2 Images to Form a Single Image

Step 1: Install cv2 Module.

command : pip install opencv-python.

|| OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed at real-time computer vision. ||

Step 2: Import cv2 and Numpy

Importing cv2 module and Importing numpy

Importing cv2 and numpy

Step 3 : Lets Read and Display the Particular Image.


cv2.imread (‘image’) #reading the image

cv2.imshow(window_name, image) #display image
cv2.waitkey(time in ms) # wait for a specific time in milliseconds
cv2.destroyAllWindows() # destroy the window after displaying the image

Image 1 :


Image 2 :

#Same Syntax

#For Reading and Display the Image.


Step 4 : Lets Check The size of our Image

#syntax : variablename.shape

Step 5 : Crop or Resize the Photo

We will Crop or Resize the photo1 in the same shape of Photo2 to get an Proper Output with the Same Size in Height and Width.

Step 6: Attach The Image Horizontally.

we will attach both the image photo1_res and photo2 horizontally by using Numpy.

#numpy.hstack((image1 ,image2))

EX: we can see as the image in the form Collage

Step 7: Output:


Hope you Find It Intresting..!!

Thank you..!!




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Capstone: Real Estate Marketplace Project FAQ — Udacity Blockchain

A New OpenQASM for a New Era of Dynamic Circuits

Top 5 tips for successful Mobile Application Testing

Here’s What’s New In Qiskit 0.20

Announcing the launch of Rakuten RapidAPI 2.0

GitHub Actions + Terratag

Creating a docker image of a web application written in Go Lang #100DaysOfCode

Modularization in Android: architecture point of view. From A to Z. Part I

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhay desai

Abhay desai

More from Medium

Push-Ups with Python! (mediapipe + Open

Create a Face Detection Algorithm Using OpenCV and Google Colab

pyIFD: Python-based Image Forgery Detection Toolkit

Cycle GANs: Generating Paintings of My Campus in Van Gogh’s Painting Style