Deblur a text image

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Post Reply
gvandyk
Posts: 15
Joined: 2015-09-08T12:40:32-07:00
Authentication code: 1151

Deblur a text image

Post by gvandyk » 2015-11-20T06:23:34-07:00

Hi

I have a text image that is blurred. I believe it is a motion blur in the horizontal direction, as I don't seem to see any vertical blurring.

An example image can be found here: https://www.dropbox.com/s/hv1izm5xgcldl ... 3.JPG?dl=0

What is the best way to "deblur" the image? Any ideas

I've tried using cameradeblur with the following:

Code: Select all

cameradeblur -t motion -a 10 -r 0 PG-00973.JPG output.jpg
but the script does not create any output

User avatar
fmw42
Posts: 22084
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Deblur a text image

Post by fmw42 » 2015-11-20T10:57:50-07:00

See my private email to you. You must compile IM in HDRI mode.

User avatar
fmw42
Posts: 22084
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Deblur a text image

Post by fmw42 » 2015-11-20T14:05:40-07:00

I think your image has too much noise to get good results. Note also that you must work with a square (subsection) image for that script. So I took a 512x512 subsection, tmp1.png

Image

Then I used my ceptstrum script to generate the cepstrum image to use to find the type of blur (motion in this case) and its arguments.

Code: Select all

im6926hdri cepstrum -c 10000 -G tmp1.png tmp1_cep10000.png
Image

Then I took the cepstrum image to the tool ImageJ and measured the line between the two central dots to get the (half)length and angle.
Image

Then I converted the image to grayscale:
convert tmp1.png -colorspace gray tmp2.png
Image

Then I ran 3 tests with those arguments and with different noise arguments. The angle directions must be reversed between the two applications.

Code: Select all

im6926hdri cameradeblur -t motion -a 14.715 -r -9.78 -n 0.05 tmp2.png tmp2_deblur_n0p05.png
Image

Code: Select all

im6926hdri cameradeblur -t motion -a 14.715 -r -9.78 -n 0.005 tmp2.png tmp2_deblur_n0p005.png
Image

Code: Select all

im6926hdri cameradeblur -t motion -a 14.715 -r -9.78 -n 0.001 tmp2.png tmp2_deblur_n0p001.png
Image

As you can see none really recover the deblurred image well due to amplification of the noise.


You might try denoising the image first. See my scripts denoise and noise cleaner. If that works, then use the IM function -deskew 40% to deskew the text so that the text is more horizontal. Then try my script, textcleaner to remove the gray background.

Post Reply