<p>I have a JPEG file with a <a href="https://www.dropbox.com/s/01ygrkzlhylu612/ACPU-128.jpg?dl=0" rel="nofollow noreferrer">200 dpi scan of a sample printout</a> from a <strong>badly maintained</strong> old drum printer. I was able to segment it and to collect <a href="https://www.dropbox.com/s/doc2bzh155mey26/tiles.zip?dl=0" rel="nofollow noreferrer">all instances of each letter together</a>, for example</p>
<p><a href="https://i.sstatic.net/ZJqH0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZJqH0.png" alt="Letters A" /></a>
<a href="https://i.sstatic.net/rFNd6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rFNd6.png" alt="Letters G" /></a>
<a href="https://i.sstatic.net/x3BwS.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/x3BwS.png" alt="Letters Q" /></a>
<a href="https://i.sstatic.net/dEohV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dEohV.png" alt="Letters W" /></a></p>
<p>I would like to recreate its font; as the first step I've written a utility that estimates the shift amount (in pixels) between two images using MSE, then weighted-averages them according to that shift amount, and continues until all instances of a character have been processed.</p>
<p>My results look like</p>
<p><a href="https://i.sstatic.net/nuumF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nuumF.png" alt="Sample result" /></a></p>
<p>Is this the best I can hope for, or are there smarter algorithms that are able to deal with low-quality samples?</p>
<p>Specifically, I would like to get rid of the ink smear at the top of the characters due to the rotational momentum of the drum with respect to the hammers.</p>
<p>(As far as I understand, <a href="https://en.wikipedia.org/wiki/Super-resolution_imaging" rel="nofollow noreferrer">super-resolution</a> is not a good match for this task, and I couldn't find a good open source implementation of it.)</p>
<p>The second step is to use <a href="https://en.wikipedia.org/wiki/Potrace" rel="nofollow noreferrer">Potrace</a>, of course.</p>

CC BY-SA 3.0
2017-05-27T13:32:50.193Z
Can it be assumed that the orientation of all instances of a character are identical? That is, that there is zero rotation?
trichoplax is on Codidact now
CC BY-SA 3.0
2017-05-27T13:33:37.863Z
Are you able to share the raw data for people to experiment?
trichoplax is on Codidact now
CC BY-SA 3.0
2017-05-27T16:44:44.147Z
@trichoplax There is a very slight consistent rotation clockwise as a scanning artifact. I've accounted for it when segmenting. There is no variation of rotation of individual characters.

[Initial image](https://www.dropbox.com/s/01ygrkzlhylu612/ACPU-128.jpg?dl=0) [Charset encoding](http://en.wikipedia.org/wiki/GOST_10859) [Segmented](https://www.dropbox.com/s/doc2bzh155mey26/tiles.zip?dl=0)
Leo B.
CC BY-SA 3.0
2017-05-29T21:58:10.173Z
Interesting indeed. just an idea- since you make own program, how is about setting different threshold by averaging, depending on which pixel row it is - say the top pixel row contributes pixels which are >95% black, second slightly more, say, all pixels which are >94% black ... and so on.
Mikhail V
CC BY-SA 3.0
2017-05-30T03:02:40.507Z
@Mikhail That's a good idea, but it definitely requires tuning.
Leo B.
CC BY-SA 3.0
2017-05-31T21:14:39.480Z
Maybe it is worth posting an image with _one_ letter (before/after filtering) in native resolution. Then probably you get more chances for real proposals. Higher resolution is better. In general removing smear can become a complex task, if you want a pure programmatical way. And I suppose it would need anyway row-by-row filtering, and to filter all chars it will need vertical aligning the glyphs or finding boundaries for each glyph.
Mikhail V
CC BY-SA 3.0
2017-05-31T21:30:00.330Z
So if your examples is the highest possible resoultion, then I'd say it is too small for post-processing.  And if something, you can always retouche the results with hand. Retouching the whole set can take a pair of evenings, but developing fully automatical software can take weeks.
Mikhail V
CC BY-SA 3.0
2017-05-31T21:38:51.010Z
@MikhailV Retouching is always an option, if everything else fails. Now I'm doing simple averaging after estimating the offset in whole pixels. I was hoping for some kind of a smarter algorithm for offset estimation and/or averaging.
Leo B.
<image-processing>
Recreating a font from a low-quality printout
Leo B.
# Recreating a font from a low-quality printout

(Asked by: username_0 on 2017-05-26)

I have a JPEG file with a [200 dpi scan of a sample printout](https://www.dropbox.com/s/01ygrkzlhylu612/ACPU-128.jpg?dl=0) from a **badly maintained** old drum printer. I was able to segment it and to collect [all instances of each letter together](https://www.dropbox.com/s/doc2bzh155mey26/tiles.zip?dl=0), for example

[![Letters A](https://i.sstatic.net/ZJqH0.png)](https://i.sstatic.net/ZJqH0.png)
[![Letters G](https://i.sstatic.net/rFNd6.png)](https://i.sstatic.net/rFNd6.png)
[![Letters Q](https://i.sstatic.net/x3BwS.png)](https://i.sstatic.net/x3BwS.png)
[![Letters W](https://i.sstatic.net/dEohV.png)](https://i.sstatic.net/dEohV.png)

I would like to recreate its font; as the first step I've written a utility that estimates the shift amount (in pixels) between two images using MSE, then weighted-averages them according to that shift amount, and continues until all instances of a character have been processed.

My results look like

[![Sample result](https://i.sstatic.net/nuumF.png)](https://i.sstatic.net/nuumF.png)

Is this the best I can hope for, or are there smarter algorithms that are able to deal with low-quality samples?

Specifically, I would like to get rid of the ink smear at the top of the characters due to the rotational momentum of the drum with respect to the hammers.

(As far as I understand, [super-resolution](https://en.wikipedia.org/wiki/Super-resolution_imaging) is not a good match for this task, and I couldn't find a good open source implementation of it.)

The second step is to use [Potrace](https://en.wikipedia.org/wiki/Potrace), of course.

**Tags:** image-processing

> **Comments:**
> **username_1**: Can it be assumed that the orientation of all instances of a character are identical? That is, that there is zero rotation?  
> **username_1**: Are you able to share the raw data for people to experiment?  
> **username_0**: @username_1 There is a very slight consistent rotation clockwise as a scanning artifact. I've accounted for it when segmenting. There is no variation of rotation of individual characters.  [Initial image](https://www.dropbox.com/s/01ygrkzlhylu612/ACPU-128.jpg?dl=0) [Charset encoding](http://en.wikipedia.org/wiki/GOST_10859) [Segmented](https://www.dropbox.com/s/doc2bzh155mey26/tiles.zip?dl=0)  
> **username_2**: Interesting indeed. just an idea- since you make own program, how is about setting different threshold by averaging, depending on which pixel row it is - say the top pixel row contributes pixels which are >95% black, second slightly more, say, all pixels which are >94% black ... and so on.  
> **username_0**: @username_2 That's a good idea, but it definitely requires tuning.  
> **username_2**: Maybe it is worth posting an image with _one_ letter (before/after filtering) in native resolution. Then probably you get more chances for real proposals. Higher resolution is better. In general removing smear can become a complex task, if you want a pure programmatical way. And I suppose it would need anyway row-by-row filtering, and to filter all chars it will need vertical aligning the glyphs or finding boundaries for each glyph.  
> **username_2**: So if your examples is the highest possible resoultion, then I'd say it is too small for post-processing.  And if something, you can always retouche the results with hand. Retouching the whole set can take a pair of evenings, but developing fully automatical software can take weeks.  
> **username_0**: @username_2 Retouching is always an option, if everything else fails. Now I'm doing simple averaging after estimating the offset in whole pixels. I was hoping for some kind of a smarter algorithm for offset estimation and/or averaging.  

---

## 0 answers

