Shwetabh Shekhar
Shwetabh Shekhar

Reputation: 3034

How can we remove one solid color from an Image?

Using the cvSet method we can easily fill an image with solid colours. Is there any method which can help you remove some colours from ur image (e.g I have an Image of a forest. Basically it will have a lot of green component, leaves etc. Can I remove the green color keeping everything else same.)

Upvotes: 4

Views: 4796

Answers (1)

Davood
Davood

Reputation: 1566

    char* inputPath = "TEST.png";

    Mat src = imread(inputPath);
    Mat BGRChannels[3];
    split(src,BGRChannels); // split the BGR channesl
    BGRChannels[1]=Mat::zeros(src.rows,src.cols,CV_8UC1);// removing Green channel
    merge(BGRChannels,3,src); // pack the image 
    namedWindow("B0R",1);
    imshow("B0R",src);
    waitKey(0);

Here is the result:
main image

removed green channel image

Upvotes: 9

Related Questions