Reputation: 53
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
Image with contours
Upvotes: 3
Views: 7348
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();
After that you can have a go with cv::findContours() to find the rectangles.
Upvotes: 1