- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Drawing borders around an image using OpenCV
In this program, we will draw borders around an image. We will use the copyMakeBorder() method in the openCV library. This function takes various parameters like image, top, bottom, left, right border values.
Original Image
Algorithm
Step 1: Import cv2. Step 2: Read the image. Step 3: Dall the cv2.copymakeborder() method. Step 4: Display the output.
Example Code
import cv2 image = cv2.imread('testimage.jpg') image = cv2.copyMakeBorder(image, 10,10,10,10, cv2.BORDER_CONSTANT) cv2.imshow('Border', image)
Output
- Related Articles
- How to add borders to an image using Java OpenCV library?
- Drawing a cross on an image with OpenCV
- OpenCV Python – How to add borders to an image?
- How to fit ellipses around possible objects in an image using OpenCV Java?
- Upsampling an image using OpenCV
- Downsampling an image using OpenCV
- Drawing an image in canvas using in JavaScript
- Draw an ellipse on an image using OpenCV
- Reading an image using Python OpenCv module
- Draw rectangle on an image using OpenCV
- Detecting contours in an image using OpenCV
- Performing an opening operation on an image using OpenCV
- How to eliminate blue borders around linked images using CSS?
- Using OpenCV in Python to Cartoonize an Image
- Draw a line on an image using OpenCV

Advertisements