user12077643
user12077643

Reputation:

Creating a mask based on a colour range

I'm trying to wind turbines in pictures. To make this easier I try to remove the background based on the color (sky is blue, ground is green) just something basic. But it seems that my mask is always completely black. What am i doing wrong?

kind regards

Mat HSV, mask, outputHSV;
    // Convert from BGR to HSV colorspace
    cv::cvtColor(frame,HSV, COLOR_BGR2HSV);

    int low_H = 220, low_S = 60, low_V = 90;
    int high_H = 240, high_S = 100, high_V = 100;

    // Detect the object based on HSV Range Values
    inRange(HSV, Scalar(low_H, low_S, low_V), Scalar(high_H, high_S, high_V), mask);

    // creating an inverted mask to segment out the cloth from the frame
    bitwise_and(frame,HSV,outputHSV,mask = mask);
    cv::imshow("HSV_filter", outputHSV);

Upvotes: 1

Views: 78

Answers (1)

Sivaram Rasathurai
Sivaram Rasathurai

Reputation: 6333

You don't need to set the threshold for the v channel. Just play with hue and saturation The HSV color space represents colors using three values

Hue : This channel encodes color color information. Hue can be thought of an angle where 0 degree corresponds to the red color, 120 degrees corresponds to the green color, and 240 degrees corresponds to the blue color.

Saturation : This channel encodes the intensity/purity of color. For example, pink is less saturated than red.

Value : This channel encodes the brightness of color. Shading and gloss components of an image appear in this channel.

int low_H = 220, low_S = 60, low_V = 0;
int high_H = 240, high_S = 100, high_V = 255;

Upvotes: 1

Related Questions