Page 1 of 1
Using Registration Marks To Crop?
Posted: 2013-08-29T07:33:59-07:00
by blobby
Hi:
I am using ImageMagick to clean up scanned black and white tiffs before passing them to our OMR (bubble mark reader) software. The problem with our forms is that they are printed out by users (from pdfs), and they come back all at slightly differnt scales, which confuses the OMR software. Currently I'm using a combination of shave (to get rid of the black lines around the edge from scanning), fuzz and trim (to crop to the edges of the printing), resize (to get them all to the same height), and gravity (to put them on a white background of a consistent size). This usually works pretty well, but it fails when there are too many marks outside the area we want to crop to.
The forms we use have barcodes in the top right and bottom left which it seems to me could be used as registration marks, or we could add some marks to the forms. What I would like is to be able to consistently scale the images so that the bubble marks are in the same position in each image. Has anyone done such a tranformation using ImageMagick (or anything else, really)?
Thanks for any input!
Blobby
Re: Using Registration Marks To Crop?
Posted: 2013-08-29T09:55:05-07:00
by fmw42
Re: Using Registration Marks To Crop?
Posted: 2013-08-29T11:20:52-07:00
by snibgo
Printing your own registration marks seems the obvious route. They need to be different to anything else on the form. You can then subimage-search for the marks, distort and crop.
Searching can take a long time, but two techniques improve performance: (a) search small (cropped) areas of the form and (b) search a resized copy of the form, eg 10%, and use this result to refine the cropped area for the full-size search.
Re: Using Registration Marks To Crop?
Posted: 2013-08-29T11:25:42-07:00
by blobby
Those distorts look like they would do the trick, but I'm not sure how I would get the coordinates for the corners. Is there a way to, for example, find a barcode in a general area, and then get the corner point from that? That seems to be the major difficulty.
Thanks,
Blobby
Edit: Hadn't seen the subimage-search post when I replied, I'll look into that. Thanks!
Re: Using Registration Marks To Crop?
Posted: 2013-08-29T11:53:30-07:00
by snibgo
If forms have different barcodes, finding them is a messy problem. It's much easier to find something that is invariant between the forms.
You can also use registration marks to detect whether, for example, a scanned form is inverted.
Re: Using Registration Marks To Crop?
Posted: 2013-08-29T11:57:09-07:00
by fmw42
If your scanned images are different sizes, then one barcode reference image will not always match well with the scanned image. Matching like that is not scale invariant. However, using a cross for a marker, will generally do better, though even that will not be totally scale invariant. Such registrations are also not rotationally invariant.
At least with crosses, you do not have to offset the match by the size of the barcode to get its upper right or lower right or lower left corners. Though you do know the size of the template. But again it will not offset correctly if the scale of the scanned image is different from the reference barcode.
Re: Using Registration Marks To Crop?
Posted: 2013-08-29T12:24:49-07:00
by blobby
snibgo wrote:If forms have different barcodes, finding them is a messy problem. It's much easier to find something that is invariant between the forms.
You can also use registration marks to detect whether, for example, a scanned form is inverted.
Well, there's one barcode in the lower left which never changes; there are two more at the top right & left which change. I'm thinking that adding some crosses to each corner might be the best solution.
Re: Using Registration Marks To Crop?
Posted: 2013-08-29T12:26:13-07:00
by blobby
fmw42 wrote:If your scanned images are different sizes, then one barcode reference image will not always match well with the scanned image. Matching like that is not scale invariant. However, using a cross for a marker, will generally do better, though even that will not be totally scale invariant. Such registrations are also not rotationally invariant.
At least with crosses, you do not have to offset the match by the size of the barcode to get its upper right or lower right or lower left corners. Though you do know the size of the template. But again it will not offset correctly if the scale of the scanned image is different from the reference barcode.
That makes sense. If I could get the coordinates of the center of 4 crosses I'd be set.
Re: Using Registration Marks To Crop?
Posted: 2013-08-29T13:02:44-07:00
by fmw42
Once you get your resulting correlation image from the subimage search (via compare), you can process it for the highest scores with something like my script, maxima, at the link below (
http://www.fmwconcepts.com/imagemagick/maxima/index.php). IM generally only reports one (best) match. You need to find the four best. My script may help you do that. See some of the examples at the reference.
Re: Using Registration Marks To Crop?
Posted: 2013-08-30T07:48:57-07:00
by blobby
Thanks, I'll try that.