Ask Your Question
0

How to remove shadow from scanned documents using OpenCV?

asked 2017-06-25 21:02:43 -0600

liuzhiyuan1225 gravatar image

updated 2020-11-02 11:34:09 -0600

I'd like to remove shadow before image binarization using OpenCV. I've tried Otsu Method and adaptive thresholding, however for images where there are large regions of shadow, these two methods will not give good results.

Any better solutions? Thanks in advance.

image description image description image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-06-26 10:28:41 -0600

image description

Mat temp1;
Mat temp2;
Mat mask;
Mat dst;
threshold(src,temp1,50,255,THRESH_OTSU);
threshold(src,temp2,50,255,THRESH_BINARY);
bitwise_not(temp1,mask);
temp2.copyTo(dst,mask);
temp1.copyTo(dst,temp2);
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-06-25 21:02:43 -0600

Seen: 1,338 times

Last updated: Jun 26 '17