Ask Your Question
0

How to remove bad lighting conditions or shadow effects in images using opencv for processing face images

asked 2016-12-05 01:22:48 -0600

Huz gravatar image

I am trying to find as solution for making the image better by removing the bad lighting effects present in photos.

edit retag flag offensive close merge delete

Comments

It is too "wide" question to get the simple answer. What kind of bad conditions did you mean?

pi-null-mezon gravatar imagepi-null-mezon ( 2016-12-05 02:02:38 -0600 )edit

your question is broad, we can't really suggest you sth. if we don't know more details.

Vintez gravatar imageVintez ( 2016-12-05 02:15:23 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-05 02:21:21 -0600

Vintez gravatar image

As I commented, it is hard do give you a Answer which is fitting your Needs, because we don't know your needs. Still on Stackoverflow is a quite common solution for a problem like this.

To prevent Link corruption I add the Answer here too:

You can convert your Image into a YUV Image and then perform a histogram equalization on the Y channel. After that convert it back to RGB (if needed). With this method, you can normalize the luminance of your Image.

Code in opencv c++ would be:

cv::cvtColor(img, img, CV_BGR2YUV);
std::vector<cv::Mat> channels;
cv::split(img, channels);
cv::equalizeHist(channels[0], channels[0]);
cv::merge(channels, img);
cv::cvtColor(img, img, CV_YUV2BGR);

For more details look at the Link and note: this is not a solution I came up with it was the solution of Aurelius from stackoverflow

edit flag offensive delete link more

Comments

How does this differ from doing a "regular" equalizeHist(img, img) without splitting the channel ?

atv gravatar imageatv ( 2016-12-05 03:06:38 -0600 )edit

The Y-Component of a YUV Image holds the Luminance Information. Normalizing the Luminance would end in the effect, that you try to normalize the Light or Darkness in a Image the effect is shown in the Answer of Aurelius. I can't tell exactly how it differs from a regular equalization as you are mentioning it (As said, it is not actually my answer) If you want to know more, try to comment the Answer in stackoverflow so Aurelius could answer it.

Vintez gravatar imageVintez ( 2016-12-05 03:52:51 -0600 )edit

Out of curiosity, if the whole image is covered by a shadow or something, how can I remove or relight shadowed area? I guess if its just nomalizing the whole image I guess I need another solution

Noobie gravatar imageNoobie ( 2017-03-28 01:01:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-05 01:22:48 -0600

Seen: 20,546 times

Last updated: Dec 05 '16