Subscribe:

Ads 468x60px

Sunday, August 5, 2012

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;   
  }   



Output






Read more about HSV Thresholding

5 comments:

Anonymous said...

OpenCV uses the BGR format, therefore try cvtColor(input,hsv, CV_BGR2HSV)

Jey Narasimhan said...

Lentin,

I am learning opencv and found your blog when looking for some examples of color space conversion. Thanks for your example. Btw, I think you don't need to include cv:: if you have the namespace line.

Dr Aye said...

HERPES CURE
I can’t believe my genital herpes is really cured, oh is by this time last year I start feeling bad about my life, I feel pain everyday of my life am very happy now that am really cured I couldn't have do this on my own I wish is not God that help me with my herpes I was searching the internet about this sickness last 3month when I found about great doctor aye, the man that keep his words I write the man email about my problem immediately I get a reply from him asking me to fill a form which I immediately did and send back to him after some mins he reply me that he have work on my cure that I need to provide some materials, which can enable him to work on my cure which I did on the next day of it, after some hours he inform me that he have getting the things needed for the cure and he is about to go on with the curing spell he called me again after 50mins that he is done with the cure that I should check my body and also go for test I cant believe I was negative a big thanks to him am very happy now with my family you can also get your self cured too from this sickness by contact him through .AYESPELLALTER@GMAIL.COM

Taylor Lillian said...

I have been suffering from (HERPES) disease for the last four years and had constant pain, especially in my knees. During the first year, I had faith in God that i would be healed someday.This disease started circulating all over my body and i have been taking treatment from my doctor, few weeks ago i was searching on the internet if i could get any information concerning the prevention of this disease, on my search i saw a testimony of someone who has been healed from GENITAL HERPES VIRUS by this Man DR.OZIGAN and she also gave the email address of this man and advise we should contact him for any sickness that he would be of help, so i wrote to DR.OZIGAN telling him about my (HERPES VIRUS) he told me not to worry that i was going to be cured!! hmm i never believed it,, well after all the procedures and remedy given to me by this man few weeks later i started experiencing changes all over me as the DR.OZIGAN assured me that i have cured, after some time i went to my doctor to confirmed if i have be finally healed behold it was TRUE So friends my advise is if you have such sickness or any other at all you can email DR.OZIGAN DR.OZIGANSPIRITUALHOME@GMAIL.COM OR DR.OZIGANSPIRITUALHOME@HOTMAIL.COM i am indeed grateful for the help, i will forever recommend you to my friends!!!

Daniel Paisley said...

A great thanks to doctor abegbe the man that work for you as a father I was having gentian herpes for 6year I never found cure I was embarrassed every time I always have pain every time am very happy for dr.abegbe who God bring as helper to me, when I found his email on internet i was shock if it was true serious the man is real he will ask you to choose for your choice of your propose of the cured he inform me about the herbs cure and the spell casting and the spell casting take 45mins to work which I applied for, once you provide what he need for the spell casting he get the necessary thing available for the cure and he go on with the cure, he inform me that the cure is done at night when will was in the night he go on with the spell casting at time I sleep off because he ask me to sleep on my bed, when I wake-up I found changing in my body I was cured I run to hopsitel for test I found out am negative thanks to doctor abegbe you can reach him on his email now DR.ABEGBESPELLHOME@HOTMAIL.COM OR DR.ABEGBESPELLHOME@GMAIL.COM or call him on +2348167022540

Post a Comment