d32
d32

Reputation: 53

How to remove shadow from image captured using mobile camera using OpenCV?

I need to find largest rectangle in a image, but when I find contours shadow becomes part of the contour.

Any suggestions how to remove/minimize shadow.

Original image

enter image description here

Image with contours

enter image description here

Upvotes: 3

Views: 7348

Answers (1)

RevJohn
RevJohn

Reputation: 1074

You can use an edge dectector like Canny:

cv::Mat image = cv::imread( "C:/Users/John/Documents/StackOverflow/t8keM.png" );
cv::Mat gray_image, dst, color_dst;

cvtColor( image, gray_image, CV_BGR2GRAY );
Canny( gray_image, dst, 50, 200, 3 );
cvtColor( dst, color_dst, CV_GRAY2BGR );

cv::imshow( "image", image );
cv::imshow( "canny", color_dst );

cv::waitKey();

With result: enter image description here

After that you can have a go with cv::findContours() to find the rectangles.

Upvotes: 1

Related Questions