I'm currently using Imagemagick to very successfully deskew images. It'd be AMAZING if i could get it to also remove the barcodes fom my images. Below is an example of what the image would look like. In a REALLY ideal world we'd somehow erase everything except the numbers .
I can't use coordinates as these end up all over the place thanks to being fed by ADF.
Tried a few forum posts based around removing vertical lines, but had no luck.
Attempting to remove poor quality barcode
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Attempting to remove poor quality barcode
The trick is to remove the barcode without also removing other important detail. In your example, after denoising, the bars are substantially larger than the text, so removing them and not the text is quite easy. But what else do your images contain? How much do bars vary (in size) between images?
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Attempting to remove poor quality barcode
If your results are this clean, then average the image down to one column and threshold to locate the darkest region. Then find the top and bottom of that region and composite a white horizontal strip of that height over that section of the original image.
Try this (unix):
Try this (unix):
Code: Select all
size=`convert -ping Capture.png -format "%wx%h" info:`
width=`echo "$size" | cut -dx -f1`
height=`echo "$size" | cut -dx -f2`
bgcolor=`convert Capture.png -format "%[pixel:u.p{0,0}]" info:`
cropvals=`convert Capture.png -resize 1x! -auto-level -threshold 50% -format "%@" info:`
ht=`echo $cropvals | cut -d+ -f1 | cut -dx -f2`
ht=$((ht+4))
yoff=`echo $cropvals | cut -d+ -f3`
yoff=$((yoff-2))
convert Capture.png -size ${width}x${ht} xc:"$bgcolor" -geometry +0+$yoff -compose over -composite Capture_clean.png
Re: Attempting to remove poor quality barcode
So nothing else on the image really matters. I'm using a UZN file with Tesseract to recognize only this part of the image.snibgo wrote: ↑2017-12-01T15:17:50-07:00 The trick is to remove the barcode without also removing other important detail. In your example, after denoising, the bars are substantially larger than the text, so removing them and not the text is quite easy. But what else do your images contain? How much do bars vary (in size) between images?
This image should give a pretty good idea of how much the bars vary in size.
They're not QUITE this clean. This is the lower righthand corner of an 8.5x11 sheet of paper. Is it possible to set a boundary on the functions you've listed?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Attempting to remove poor quality barcode
Can you be more specific? Boundary on what?depthless wrote:They're not QUITE this clean. This is the lower righthand corner of an 8.5x11 sheet of paper. Is it possible to set a boundary on the functions you've listed?
My method requires that you isolate the region where the barcode exists, since it is distinguished by being the darkest contiguous vertical section in the image. So you would have to crop out this region and then process it, then paste it back in. Not much to be gained this way, since you have to crop manually, unless the barcode is in the same region in all images.