Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Detecting convex quadrilaterals on photo with strong noisy background

My goal is to detect convex quadrilaterals on photo with some strong noisy background. There're plenty of articles & answers related to detecting of quadrilaterals on photo, but almost all of them are efficient only for some cases and useless in case of having some strong background.

An example of such photo is below (in this photo I'm interested in only one quadrilateral - napkin):

image description

I use the following steps to detect quadrilaterals:

  • Applying ctvColor() for converting to gray
  • Applying blur()
  • Applying Canny filter with auto-calculated thresholds (using OTSU threshold)
  • Finding contours using findContours() with RETR_LIST type
  • (optional) Applying approxPolyDP() for contours

The issue here is that number of found contours is too big, but I need the only one (white napkin in my case), as a result findContours() is extremely slow. I've tried several approaches to improve this algorithm (reduce number of found contours):

  • Using strong blur (ksize > 20)
  • Applying morphologyEx() before Canny filter
  • Scaling bitmap before applying all other operations

These operations help a little bit, but at the same time they bring other issues. so the best result at the moment (with big blur, morphologyEx and scaling) is below and it is insufficient:

image description

It seems I made some mistakes, could you please advise how can I detect quadrilaterals in such cases? The goal is to be able to find quadrilaterals on different complex surfaces which contain other contours, like a brick wall.