image processing - Algorithm to detect corners of paper sheet in photo -
what best way detect corners of invoice/receipt/sheet-of-paper in photo? used subsequent perspective correction, before ocr.
my current approach has been:
rgb > gray > canny edge detection thresholding > dilate(1) > remove small objects(6) > clear boarder objects > pick larges blog based on convex area. > [corner detection - not implemented]
i can't think there must more robust 'intelligent'/statistical approach handle type of segmentation. don't have lot of training examples, 100 images together.
broader context:
i'm using matlab prototype, , planning implement system in opencv , tesserect-ocr. first of number of image processing problems need solve specific application. i'm looking roll own solution , re-familiarize myself image processing algorithms.
here sample image i'd algorithm handle: if you'd take challenge large images @ http://madteckhead.com/tmp
case 1 http://madteckhead.com/tmp/img_0773_sml.jpg case 2 http://madteckhead.com/tmp/img_0774_sml.jpg case 3 http://madteckhead.com/tmp/img_0775_sml.jpg case 4 http://madteckhead.com/tmp/img_0776_sml.jpg
in best case gives:
case 1 - canny http://madteckhead.com/tmp/img_0773_canny.jpg case 1 - post canny http://madteckhead.com/tmp/img_0773_postcanny.jpg case 1 - largest blog http://madteckhead.com/tmp/img_0773_blob.jpg
however fails on other cases:
case 2 - canny http://madteckhead.com/tmp/img_0774_canny.jpg case 2 - post canny http://madteckhead.com/tmp/img_0774_postcanny.jpg case 2 - largest blog http://madteckhead.com/tmp/img_0774_blob.jpg
thanks in advance great ideas! love so!
edit: hough transform progress
q: algorithm cluster hough lines find corners? following advice answers able use hough transform, pick lines, , filter them. current approach rather crude. i've made assumption invoice less 15deg out of alignment image. end reasonable results lines if case (see below). not entirely sure of suitable algorithm cluster lines (or vote) extrapolate corners. hough lines not continuous. , in noisy images, there can parallel lines form or distance line origin metrics required. ideas?
case 1 http://madteckhead.com/tmp/img_0773_hough.jpg case 2 http://madteckhead.com/tmp/img_0774_hough.jpg case 3 http://madteckhead.com/tmp/img_0775_hough.jpg case 4 http://madteckhead.com/tmp/img_0776_hough.jpg
i'm martin's friend working on earlier year. first ever coding project, , kinda ended in bit of rush, code needs errr...decoding... i'll give few tips i've seen doing already, , sort code on day off tomorrow.
first tip, opencv
, python
awesome, move them possible. :d
instead of removing small objects , or noise, lower canny restraints, accepts more edges, , find largest closed contour (in opencv use findcontour()
simple parameters, think used cv_retr_list
). might still struggle when it's on white piece of paper, providing best results.
for houghline2()
transform, try cv_hough_standard
opposed cv_hough_probabilistic
, it'll give rho , theta values, defining line in polar coordinates, , can group lines within tolerance those.
my grouping worked table, each line outputted hough transform give rho , theta pair. if these values within, 5% of pair of values in table, discarded, if outside 5%, new entry added table.
you can analysis of parallel lines or distance between lines more easily.
hope helps.
Comments
Post a Comment