Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Atalasoft Staff Blog

This is where Atalasoft Staff members will post on topics such as new KB articles, Demos, sample code, or just Atalasoft Information.

Cleaning Up a Barcode Image

Whenever a page is scanned into a digital format, there is inevitably some noise that will accompany the image data.  DotImage provides many ways to 'clean up' and image, especially a document (or 1-bit) image, but these methods are often overlooked.
 
I came across an image of a barcode the other day, which needed to be cleaned up.  The barcode contained a good amount of noise and would not recognize correctly.  The background of the image was white and the barcode was black, a standard 1-bit image.  There was noise in the background in the form of little black specks, but the noise on the barcode was little white specks, since the barcode is black. 
 
Naturally I thought to use our DocumentDespeckleCommand which got rid of the black specks very nicely.  Somewhat to my surprise this did not remove any of the white specks in the barcode.  After a moment I thought to myself, of course, the despeckle command is looking for BLACK specks, not white.  So then how do I get rid of the white specks?  Well this calls for a different method all together, possibly a lesser known command.
 
The MorphoDocumentCommand can be used to apply a few different mathematical morphological operations to a binary image.  Morphological operations are used to change the form and structure of an object.  For a document image, we can think of the 'object' as the text contained in the image.  To clean up a barcode image, I used the 'Close' method.  This will have the effect of 'filling in' the white specks in the barcode.  Now I can recognize the barcode without a problem.
 
Any document cleanup command will work best on an image that was scanned at a high resolution, and this is no exception.  So remember as a general rule, the more image data (number of pixels) you have, the better chance you have for cleaning up the image.







Original Barcode

Barcode after Morphological Close filter applied

Published Friday, February 17, 2006 4:32 PM by Sean Mckenna

Comments

No Comments
Anonymous comments are disabled