Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we remove one solid color from an Image?

Tags:

opencv

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.)

like image 466
Shwetabh Shekhar Avatar asked Jan 07 '23 19:01

Shwetabh Shekhar


1 Answers

    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

like image 54
Davood Falahati Avatar answered Feb 12 '23 17:02

Davood Falahati