how to make canny edge detection invariant to image size?

asked 2017-09-06 10:25:49 -0500

I'm trying to implement a document scanner following http://www.pyimagesearch.com/2014/09/01/build-kick-ass-mobile-document-scanner-just-5-minutes/

however, I found out that the method is very sensitive to image size.

when the image is very large, the canny edge detector tends to draw very thin edge lines, so thin that at certain areas, the edge lines disjoint.

And then the next step findContour function would fail.

how to make canny edge detection invariant to image size? Thanks.

edit retag flag offensive close merge delete

Comments

please post your code if it is C++. there is a similar case i want to improve it.

sturkmen gravatar imagesturkmen ( 2017-09-06 11:00:04 -0500 )edit

my code is in c++, but on a different computer, I can't paste it now. but my code is nothing special, it's a faithful translation of the above python code.

billconan gravatar imagebillconan ( 2017-09-06 11:18:18 -0500 )edit

OK. i will try to do some improvements on your code when you able to paste it.

sturkmen gravatar imagesturkmen ( 2017-09-06 11:23:07 -0500 )edit

Actually, replacing the findContours by a convexHull on all active white pixels might be a better solution, given the sample contains only a single image. So do your findContours, concatenate all found contours and apply a convexHull on that large set of points. that will always return the paper.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-09-07 02:26:45 -0500 )edit