I am using opencv edge and contour detection to crop some objects. now thatt object contain two or more colors so I have to change that colors one by one, for ecample I want to
I done it in this way. Hope it would help someone:
imageView.image=[UIImage imageNamed:@"test.png"];
cv::Mat img=[self cvMatFromUIImage:imageView.image];
cv::Mat hsvImage=cvCreateImage(img.size(),8, 3);
cv::cvtColor(img, hsvImage, CV_BGR2HSV);
std::vector<cv::Mat>channels;
cv::split(hsvImage, channels);
cv::Mat hue = channels[0];
cv::Mat dest;
cv::Mat temp=cvCreateImage(img.size(), 8, 3);
cv::inRange(hsvImage, cv::Scalar(90,50,50), cv::Scalar(130,255,255), dest);
cv::merge(channels, temp);
temp.setTo(cv::Scalar(60,255,255),dest);
cv::split(temp, channels);
cv::merge(channels, dest);
cv::cvtColor(dest, hsvImage, CV_HSV2BGR);
imageView.image=[self UIImageFromCVMat:hsvImage];