3

I have scanned a signature and that looks like this

Scanned signature

I want to smooth it. I saw this post where they do this using Photoshop or GIMP.

I tried to replicate that in Mathematica so I can automatize the process since I have to run this on 50+ signatures.

What I did was

image = Import["path/to/my/image"];

ImageResize[Threshold[  GaussianFilter[ImageResize[image, Scaled[2]], 5], {"Hard", "Cluster"}], 400]

And got this

Processed signature

It looks smoother but also a little bit blurry. I think I got a better result with GIMP but it will take a lot of time if I do that by hand 50+ times.

This is what I got with GIMP

GIMP result

Any idea how to improve this?

==UPDATE==

I got something a little bit better

smooth[img_]:=Block[{data,nimg=ImageResize[Opening[Threshold[GaussianFilter[ImageResize[img,Scaled[2]],5],{"Hard","Cluster"}],DiskMatrix[2]],400]},data=ImageData[nimg];ImageAdd[nimg,Blur[ColorNegate@Erosion[DeleteSmallComponents[Dilation[ColorNegate@Binarize[Image[data/.{x_,y_,z_}/;EuclideanDistance[{x,y,z},data[[45,45]]]<0.05->{1,1,1}],.99],4]],3],5]]]

This gives me

Better result

Part of this came from this post.

xtian777x
  • 1,018
  • 8
  • 14

1 Answers1

4

You probably won't achieve exactly the same effect in Mathematica as you will with GIMP, but I think this is pretty close:

ColorConvert[
 ImageAdjust[
  MeanShiftFilter[ImageAdjust[ImageAdjust[image, {0, 0, 2}]], 
   5, .1], {1, 0}], "Grayscale"]

Mathematica graphics

shrx
  • 7,807
  • 2
  • 22
  • 55