Skip to content

irebased/naive_barcode_correction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Barcode corrector

An attempt to evaluate barcodes that have lost some fidelity due to image compression. Works by:

  1. Grayscale the barcode
  2. Taking the first row of the barcode image's pixels
  3. Converting to hex values for numeric comparisons
  4. Find local maxima (white) and minima (black) and make them actual black/white in the corrected barcode
  5. Between local minima and maxima, find the midpoint of the gradient and split evenly left/right for white/black.

This is an approximation, it is not perfect.

Run

  1. Install dependencies: pip install -r requirements.txt
  2. Run python main.py to see the generated barcode. The image will also be saved as corrected_barcode.png and an image of the analysis will be saved as barcode_analysis.png.

A sample barcode.png is included, which is the image I was trying to fix when building this utility.

About

Barcode correction algorithm to attempt to correct barcodes that have been compressed

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages