Detecting convex quadrilaterals on photo with strong noisy background

asked 2015-07-06 07:25:56 -0600

xzen gravatar image

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.

edit retag flag offensive close merge delete

Comments

I think you shall use another slightly different approach in this case, like using moments after detecting the quadrilaterals for detecting the biggest one, or filtering the contours, after creating approximations of quadrilaterals...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-07-06 09:02:29 -0600 )edit