Subscribe:

Ads 468x60px

Showing posts with label Opencv and HSV. Show all posts
Showing posts with label Opencv and HSV. Show all posts

Sunday, August 5, 2026

How to convert RGB to HSV using OpenCV

Hey 

 I am sharing a simple program  which convert RGB image into HSV color space. I am handling cv::Mat instead of IplImage.

hsv.cpp

  /// HSV Conversion  
 #include "opencv2/highgui/highgui.hpp"   
 #include "opencv/cv.h"  
 #include <iostream>   
 #include <stdio.h>   
 using namespace std;   
 using namespace cv;   
  int main(int argc,   
   char *argv[]   
  )   
  {   
  /// input and hsv image variable  
  cv::Mat input,hsv;  
  input =imread(argv[1],1);  
  ///hsv conversion  
  cvtColor(input,hsv,CV_RGB2HSV);  
 ///displaying hsv and input  
  cv::imshow("hsv",hsv);  
  cv::imshow("input",input);  
  waitKey();   
  return 0;   
  }