I'm doing a document edge detection software. My code works well with the high contrast, smooth background images but now I'm testing it in a complex environment.
For example, image below shows my problem
Is it possible, using OpenCV to get rid of the wiggly artifacts and preserve straight document outline for later processing?
I tried, dilation, erosion, opening, closing and other morphological operations, however problem is that artifacts are of same 'weight' as content itself.
Process is:
- resizing image
- doing multiple edge preserving blurs
- canny edge detection
- dilation with 2x2 kernel
- getting contours
- finding polygon with largest surface
Artifact connected to the label is screwing things.
Disconnected artifacts are not a major concern.
Here is the original image (scaled):