#include #include #include #include using namespace cv; int main(){ Mat img = imread("milka.jpg", IMREAD_COLOR); Mat hsv; Mat dest; Mat dest2; cvtColor(img, hsv, COLOR_BGR2HSV); Mat_ hs = hsv; Vec3b c; for(int i = 0; i < img.rows; i++){ for(int j = 0; j < img.cols; j++){ c = hsv.at(i,j); if(c[0] > 120){ hsv.at(i,j)[0] = 0; //h csatornan mindent 0-ra szinezunk } } } for(auto& c : hs){ if(c[0] > 120){ c[0] = 0; } } cvtColor(hsv, dest, COLOR_HSV2BGR); cvtColor(hs, dest2, COLOR_HSV2BGR); imshow("img", img); imshow("hsv", dest); imshow("hs", dest2); waitKey(); return 0; }