course content

Course Content

Python for Data Science: Image Handling

Border to an ImageBorder to an Image

In OpenCV, the cv2.copyMakeBorder() function is used to add a border to an image. The function creates a new image with a border of a specified size and color around the original image. The function takes in six required parameters: the image to be modified, the size of the border (specified as a tuple of pixels), the border type, the color of the border (specified as a tuple of Red, Green, Blue and Alpha values), and the number of pixels in each direction (top, bottom, left, right) to be added.


  1. Use the copyMakeBorder() function.
  2. Add a border to "image1.jpg".

Everything was clear?

Section 1. Chapter 8