1

I have a photo of a paper that I hold up to my webcam, and want to minimize the area of the photo to just the paper. This way, my OCR program will potentially be more accurate, as well as conceivably faster.

I have taken a couple steps thus far to isolate the paper from the background.

First, I use Canny Edge detection, set with high thresholds. This provides a two-color representation of the edges of my image. On it, I can see a rounded rectangle among some other artifacts that happen to have sharp edges in the background.

Next, I use a Hough transformation, to draw vectors with over 100 point hits in polar coordinates on a black background. The resulting image is as shown:

The lines drawn over the longest edges of the image

See that large (the largest), almost-rectangular figure right in the middle? That's the paper I'm holding. I need to isolate that trapezoid as a polygon, or somehow otherwise get the coordinates of its vertices.

I can use these coordinates on the original image to isolate a PNG of the paper and nothing else.

I would also highly appreciate if you could provide answers to any of these three sub-questions.

-How do you find the locations of the intersections of these lines on the image?

-How would I get rid of any lines that don't form the center trapezoidal polygon?

-With these points, is there anything better than convex hull that would allow me only to get the trapezoidal/rectangular shaped region of the image?

Here is another example, in which my program produced a better image:

enter image description here

Sid G.
  • 100
  • 1
  • 9
  • I can see multiple trapezoids and not figure out which one you definitely mean. How is a computer supposed to do that? You could possibly try to find the largest and most rectangular one. Also there must have been a step after the hough transformation since hough only yields points ("The two distinctly bright spots" in [the example](https://en.wikipedia.org/wiki/Hough_transform#Example)), turning those into lines in image coordinates means the algorithm had the information you need (position and direction of those lines, you can then math out where the intersections are). – zapl Jun 10 '16 at 07:15
  • not that i'm picky neither can i prove some help - but can you outline the rectangle of your sheed? i can't see which of these you mean – Martin Frank Jun 10 '16 at 07:15
  • I have edited the image to make what I am referring to more clear. It should also be noted that I would normally hold the paper such that the image would display it more rectangularly. As far as this question is concerned, I need to use only this image in order to produce the locations of the intersections of the bounding points. – Sid G. Jun 10 '16 at 07:25

0 Answers0