

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write an image to a file using OpenCV?
In this program, we will write an image or save an image to a file using OpenCV.
Algorithm
Step 1: Import cv2 Step 2: Read the image using opencv.imread() Step 3: Save the image using opencv.imwrite(filename, image)
Example Code
import cv2 import os image = cv2.imread('testimage.jpg') directory = r'C:\Users\prasa\Desktop' os.chdir(directory) cv2.imwrite('CAMERAMAN.jpg', image)
Output
This program will save the image in the directory as same as the original image directory
Explanation
Ensure that you have set the proper directory in order for the program to execute without errors.
- Related Questions & Answers
- How to write an image using Java OpenCV library?
- Upsampling an image using OpenCV
- Downsampling an image using OpenCV
- How to flip an image using Java OpenCV library?
- How to rotate an image with OpenCV using Java?
- How to read an image using Java OpenCV library?
- How to save an Image in OpenCV using C++?
- How to rotate an image in OpenCV using C++?
- How to write an image file in internal storage in android?
- How to add noise to an image using Java OpenCV library?
- How to add text to an image using Java OpenCV library?
- How to add borders to an image using Java OpenCV library?
- How to create a watermark on an image using Java OpenCV library?
- How to put a text in an image in OpenCV using C++?
- Draw a line on an image using OpenCV
Advertisements