
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Convert HSV to BGR Image Using Java OpenCV Library
The cvtColor() method of the Imgproc class changes/converts the color of the image from one to another. This method accepts three parameters −
src − A Matrix object representing source.
dst − A Matrix object representing the destination.
code − An integer value representing the color of the destination image.
To convert an HSV image to BGR you need to pass Imgproc.COLOR_HSV2BGR as the 3rd parameter to the cvtColor() method.
Example
public class HSV2RGB { public static void main(String args[]) throws Exception { System.loadLibrary( Core.NATIVE_LIBRARY_NAME ); Mat src = Imgcodecs.imread("D:\images\hsvimage2.jpg"); Mat dst = new Mat(); Imgproc.cvtColor(src, dst, Imgproc.COLOR_HSV2BGR); Imgcodecs imageCodecs = new Imgcodecs(); imageCodecs.imwrite("D:\images\hsv2bgr.jpg", dst); System.out.println("Image Saved"); } }
Input
Output
Advertisements