Ask Your Question
0

To reduce yellow component in image?

asked 2014-02-14 13:26:38 -0600

I was trying to implement tone mapping in opencv by using logarithmic mapping, but the result I got was yellowish image. So I want to reduce yellow component in image and increase other colors.Any suggestion or advice would be appreciated. Thank u.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-02-17 05:56:04 -0600

The best way to do this is by using the HSV color space, which makes it easier to manipulate colors

First convert color space:

Mat RGBmat;
Mat HSVmat;
cvtColor(RGBmat, HSVmat, CV_RGB2HSV);

Then filter the yellow colors of the image. You can check the HSV color space intervals in this link .

The color component of the HSV color space is mainly controled by the H channel. The S stands for saturation, V stands for value and H stands for hue

To get each channel you have to split the initial Mat:

Mat HSVchannels[3];
cv::split(HSVmat, HSVchannels);

HSVchannels[0] is a Mat with values that range between 0 and 255, and the yellow tones are between 20 and 40 (this was a really rough estimation by looking at the chart in the link above).

You can threshold the HSVchannels[0] to get only the yellow values

Mat aux = (HSVchannels[0] < 40);
Mat yellow = (aux > 20);

Then, you just manipulate the yellow mat as you wish. You can also change the V and S mat values that correspond to the yellow pixels to change lower brightness and saturation.

After manipulation the channels, you have to merge them back into one 3 channel matrix:

Mat newHSV;
Mat newRGB;
cv::merge(HSVchannels, newHSV);
cv::cvtColor(newHSV, newRGB, CV_HSV2RGB); //change it back to RGB

Good luck

edit flag offensive delete link more
0

answered 2014-02-17 01:23:59 -0600

prakharmohan gravatar image

You can apply a filter and use the RGB values to detect the level of the primary colors that are present in an image. After that you can edit the levels so as to reduce the yellow component in the image.

You can get the scalar values using cvGet2D (don't know what the name is in the current documentation) and use this to find out the levels. Then you can create your own Scalar from this and convert it into an image using cvSet2D (again check documentation for current name).

Hope this helps :)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-02-14 13:26:38 -0600

Seen: 3,246 times

Last updated: Feb 17 '14