Ask Your Question
1

How to remove shadow of image with help of open cv.?

asked 2015-07-16 00:31:02 -0600

deepak7855 gravatar image

updated 2015-07-16 00:39:35 -0600

berak gravatar image

I was tried many none of them help me out.

Like :- cv::Mat grayMat;

cv::cvtColor( cvMat, grayMat, CV_BGR2GRAY );
cv::GaussianBlur(grayMat, grayMat, cvSize(9,9), 0);
cv::adaptiveThreshold(grayMat, grayMat, 220, 0, 0, 11, 3);

This code remove the shadow.but also make whole background of image white.but i didn't want to whole image background white.I am wanting black and white image without shadow.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-07-16 02:48:45 -0600

Daniil Osokin gravatar image

Shadow removal issue usually can be divided on two subtasks:

  1. Shadow localization.
  2. Adjusting colors in shadowed regions.

Although there are a lot of papers on this topic, you can make a solution prototype with a few OpenCV functions:

  1. Try to localize shadow area with threshold.
  2. Solve a system of linear equations with cv::solve() to restore pixel's color in shadowed regions, like color_of_pixel_outside_shadow = x * color_of_pixel_inside_shadow, so 'x' will be a coefficient to restore original color. Also you can try to use cv::inpaint() for shadowed regions.
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-07-16 00:31:02 -0600

Seen: 2,687 times

Last updated: Jul 16 '15