2013-01-18 15 views

답변

0

당신은 RGB 이미지가있는 경우 다음 단지

cvtColor(img_rgb,img_hsv,CV_RGB2HSV); 

을이 당신이 원하는 무엇인가? 당신이 원하는 무엇

편집

for(int row=0;row<height;row++) 
{ 
    for(int col=0;col<width;col++) 
    { 
     Vec3b data = image_rgb.at<Vec3b>(row,col); 

     Vec3b data_hsv; 
     data_hsv[0] = // process red channel of pixel with data[0] 
     data_hsv[1] = // process green channel of pixel with data[1] 
     data_hsv[2] = // process blue channel of pixel with data[2] 


     image_hsv.at<Vec3b>(row,col)[0] = data_hsv[0]; 
     image_hsv.at<Vec3b>(row,col)[1] = data_hsv[1]; 
     image_hsv.at<Vec3b>(row,col)[2] = data_hsv[2]; 
    } 
} 
+0

실제로 저는 inbuilt opencv 함수를 사용하지 않고 수학 공식을 사용하여 변환하려고합니다. – nisargthakkar

0

merge()입니다. C++에서 :

// Assuming you have the H, S, and V images 
std::vector<cv::Mat> channels; 
channels.push_back(h); 
channels.push_back(s); 
channels.push_back(v); 

cv::Mat hsv; 
cv::merge(channels, hsv); 

// Now you can display it 
cv::imshow("HSV", hsv);