Smoothing scanned text jagged/rough edges using Hit-And-Miss

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ashvant
Posts: 2
Joined: 2013-02-15T08:35:01-07:00
Authentication code: 6789

Smoothing scanned text jagged/rough edges using Hit-And-Miss

Post by ashvant »

Hi, short and sweet

Input: Scanned text pages, pure black/white pixels with rough/jagged edges
Image
What I have done so far
file.jpg -> -depth 1 -compress none binarized.pgm -> HMT Thicken, Thinning using custom kernels -> Adaptive blur 0x0.55

What I wish for?
I will be using these images further down the stream as input to potrace, OCR and stuffs. Before that I want the text enhanced further morphologically.

What morphological changes I would love to have?
In the jagged/staircase edge, is it possible to fill the triangular part with black color so that they may look more curved than rough? Something like the bottom right character where I have painted the rough edges. How to achieve this.

Assumptions:
No background image
No colors
No skews

P.S: Am just an entry level to ImageMagick or image enhancement. Please forgive my ignorance if the answer is very obvious or simple.

Between, I LOVE IMAGEMAGICK :)
Wolfgang Woehl
Posts: 34
Joined: 2010-02-25T15:22:50-07:00
Authentication code: 8675308

Re: Smoothing scanned text jagged/rough edges using Hit-And-

Post by Wolfgang Woehl »

Just FYI: Tesseract recognizes all lines in your sample correctly.
ashvant
Posts: 2
Joined: 2013-02-15T08:35:01-07:00
Authentication code: 6789

Re: Smoothing scanned text jagged/rough edges using Hit-And-

Post by ashvant »

Hi,

My ultimate goal is to convert the source image into an enhanced, cleaner final image(The final artifact). OCR is just another assisting tool in my workflow. In other words am worried more with visually pleasantness than OCR accuracy.

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Smoothing scanned text jagged/rough edges using Hit-And-

Post by snibgo »

That letter "d" looks as if it has been crudely enlarged from a small version. So, as a first attempt, I screen-caught the letter, shrunk it to (very approximately) the original size, and re-enlarged it using IM's more sophisticated methods.

Code: Select all

convert d.png -resize 23x30! -resize 232x303! -threshold 50% dr.png
The result is already (IMO) more pleasing than your hand-drawn version, although it has rounded off the sharp corners of the vertical. Getting the scale-down exactly right would probably be even better.
snibgo's IM pages: im.snibgo.com
Post Reply