cvtColor BGR to HSV

asked 2015-09-26 05:25:17 -0500

Berkay gravatar image

updated 2015-09-26 05:29:47 -0500

berak gravatar image

Hi, below program does not work, ı can build without error but when ı click "start without debug" it gives error which is about cvtColor(); what should ı do? how can ı convert ranged image to HSV form?

#include "stdafx.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace std;
using namespace cv;

Mat redFilter(const Mat& src){

    Mat redOnly;

    inRange(src, Scalar(0, 0, 0), Scalar(0, 0, 255), redOnly);

    return redOnly;

int main(int argc, char** argv){

    Mat img_thrsld, img_trans, input = imread("sekiller2.png");
    imshow("input", input);

    Mat redOnly = redFilter(input);

    cvtColor(redOnly, img_trans, CV_BGR2GRAY);

    return 0;
edit retag flag offensive close merge delete


please add the exact error to your question

( also, your inRange() call overwrites your redOnly img, and returns a 1 channel binary img. you cannot call cvtColor(... BGR2GRAY) on that. )

what did you try to achieve ?

berak gravatar imageberak ( 2015-09-26 05:30:47 -0500 )edit