COMBINE 2 IMAGES TO FORM A SINGLE IMAGE

PRE-REQUITIES ::

* Install cv2 module
command: pip install OpenCV-python

|| OpenCV is a cross-platform library using which we can develop real-time computer vision applications.

**It mainly focuses on image processing, video capture and analysis including features like face detection and object detection.

|| OpenCV-Python makes use of Numpy , which is a highly optimized library for numerical operations with a MATLAB-style syntax.

1.Import cv2 and numpy.

2. Load Images.

* cv2.imread() :: loads an image from the specified file.
SYNTAX: cv2.imread (path)

3. Crop the images

By this slicing, images get halved

4. See the desired output.

# Add an image in the window : display  
SYNTAX :: cv2.imshow (window_name, image)
# wait for a specific time in milliseconds
SYNTAX :: cv2.waitKey()
# Destroys the window showing image
SYNTAX :: cv2.destroyAllWindows()

OUTPUT :

5. we are going to take 4 images.

6. Make all images of same size.

SYNTAX: resizeImg = cv2.resize(img, (new_w, new_h))

7. To attach images.

* numpy.hstack() function is used to stack the sequence of input arrays horizontally (i.e. column wise) to make a single array. SYNTAX : numpy.hstack (tup)
Where,
tup - sequence of ndarrays

8. To combine images.

* numpy.vstack() function is used to stack the sequence of input arrays vertically (i.e. row wise) to make a single array.SYNTAX : numpy.vstack (tup)
Where,
tup - sequence of ndarrays

9. See the desired output.

# Add an image in the window : display  
SYNTAX :: cv2.imshow (window_name, image)
# wait for a specific time in milliseconds
SYNTAX :: cv2.waitKey()
# Destroys the window showing image
SYNTAX :: cv2.destroyAllWindows()

FINAL CODE :

OUTPUT ::

DONE !!!

--

--

--

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

Recommended from Medium

Continuous Integration with Jenkins

Install Vst Plugin Dll

Creating your own local YUM repository

Contribution to Mozilla Firefox

Python packaging walk-through (with explanations)

Code Smell 48 — Code Without Standards

Confirming Varnish cache status for a page

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
Saranya. S

Saranya. S

More from Medium

SigintOS with SDR demos

How to Integrate SAWO SDK to your Vue code.

Creating Own Image By OpenCV(35)

Static and dynamic library, the differences ?