Playing with OpenCV in Python

  • Create a basic image using just numpy and cv2.
  • Crop image and replacing some part of it with another image
  • stacking two images together

Creating images with numpy and cv2

Before I give the example I would like to give an idea of what an image is computationally. We see image as the object it represents however for cv2 it is just a numpy array with different values of BGR colours stacked together.

Cropping and swapping

Here we will be cropping part of one image and replacing it to the part of the second image.

Concatenating images

For the final part we will be stacking two images .



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