Adding borders to the images using Python - OpenCV Last Updated : 03 Jan, 2023 Comments Improve Suggest changes Like Article Like Report Image processing is an interesting field in today's era of Artificial Intelligence and Machine Learning. We can see the applications of image processing in our day-to-day life, like whenever we apply filter over any image (selfie) or when we want to apply some effect like blurring the image, etc. In this article, we will discuss how to add borders to an image using Python. Python provides a module called OpenCV that can be used for the same. So before adding borders let's see a small introduction about OpenCV. OpenCV (Open Source Computer Vision Library) It is an open-source library.Designed to solve Computer Vision problems.It makes use of a highly optimized library for numerical operations which is Numpy along with MATLAB style syntax. To add borders to the images OpenCV has a package copyMakeBorder which helps to make a border around the image. Syntax: cv2.copyMakeBorder() Parameters of copyMakeBorder: inputImagetopBorderWidthbottomBorderWidthleftBorderWidthrightBorderWidthcv2.BORDER_CONSTANTvalue=color of border Input Image: Example: Python3 # importing required packages import cv2 # reading the image virat_img = cv2.imread('geek.jpg') # making border around image using copyMakeBorder borderoutput = cv2.copyMakeBorder( virat_img, 20, 20, 20, 20, cv2.BORDER_CONSTANT, value=[255, 255, 0]) # showing the image with border cv2.imwrite('output.png', borderoutput) Output: Comment More infoAdvertise with us Next Article Adding borders to the images using Python - OpenCV T tushardhiman1999 Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2020 OpenCV Python-OpenCV +1 More Practice Tags : python Similar Reads Adding Text on Image using Python - PIL In Python to open an image, image editing, saving that image in different formats one additional library called Python Imaging Library (PIL). Using this PIL we can do so many operations on images like create a new Image, edit an existing image, rotate an image, etc. For adding text we have to follow 2 min read Add image to a live camera feed using OpenCV-Python In this article, we are going to learn how to insert an image in your live camera feed using OpenCV in Python. Stepwise ImplementationStep 1: Importing the libraries CV reads and stores all the images as a NumPy array. We need the NumPy library to manipulate the image and as expected we need the cv2 4 min read Creating Hybrid Images Using OpenCV Library | Python Hybrid image, or "multi-scale image", is an exciting concept in computer vision. They are created by blending one image's high-frequency components with another's low-frequency components. The result is an image that appears as one when viewed from a distance but shows a different image when viewed 4 min read How to subtract two images using Python-OpenCV ? In this article, we are going to see how to subtract two images using OpenCV in Python. Now, before getting into the topic we shall discuss some of the use cases of Arithmetic operations. Arithmetic operations like addition and subtraction can help us to make images brighter or darker. Specifically, 3 min read How to rotate an image using Python? Image rotation in Python rotates an image around its centre by a specified angle using forward or inverse methods. When the angle isnât a multiple of 90 degrees, parts of the image may move outside the visible boundaries and get clipped. To avoid losing important content during rotation you need pro 3 min read Like