2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Please include the "desired" (GIMP) result image $\endgroup$ – Dr. belisarius Apr 12 '15 at 1:25
  • 1
    $\begingroup$ Just in case GIMP has a batch mode $\endgroup$ – Dr. belisarius Apr 12 '15 at 1:32
  • $\begingroup$ Added GIMP result. I'll take a look at GIMP batch mode but would like to do it with Mathematica too. $\endgroup$ – xtian777x Apr 12 '15 at 2:53
4
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Sweet! I'll take this as a reference and try to improve it. Thanks so much! $\endgroup$ – xtian777x Apr 14 '15 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.