Page 1 of 1

How to clean image and get only the signature

Posted: 2017-06-07T12:33:30-07:00
by filipemansano
Hey!

I trying to remove background and horizontal line in bottom of signature
But the result contains many noises and traces of bottom horizontal line


i'm trying to get only the signature from this image

Original image
http://imgur.com/a/Zyith
(This image is a sample, the script will treat several different images with the same pattern)

Expected Result
http://imgur.com/a/6DSio
(For this result I used Adobe Photoshop)


Result using ImageMagick
http://imgur.com/a/hBPCp

Code used

Code: Select all

C:\imagick\bin\convert.exe ^
  teste.png ^
  -write mpr:ORG ^
  ( +clone ^
    -negate ^
    -morphology Erode rectangle:100x1 ^
    -mask mpr:ORG -morphology Dilate rectangle:100x1 ^
    +mask ^
  )^
  -compose CopyGreen -composite ^
  -normalize ^
  -fuzz 30000 -fill white -opaque "#47FF47" ^
  -fuzz 15000 -fill white -opaque "#FF00FF" ^
  -density 288 -antialias -sharpen 0x3.0 -colorspace GRAY ^
  out.png
  
Version: ImageMagick 6.8.9-1

Re: How to clean image and get only the signature

Posted: 2017-06-07T12:42:20-07:00
by Bonzo
Out of interest why do you want the signature? If it is your signature you have it already from Photoshop.

Re: How to clean image and get only the signature

Posted: 2017-06-07T12:45:48-07:00
by filipemansano
Bonzo wrote: 2017-06-07T12:42:20-07:00 Out of interest why do you want the signature? If it is your signature you have it already from Photoshop.
Our clients send the signed contract in our internal system and we want to compare their signature, for that we only need the signature, and extracting the signature with photoshop demands a lot of time and skill of the collaborators

Re: How to clean image and get only the signature

Posted: 2017-06-07T13:35:02-07:00
by fmw42
try

Code: Select all

convert GvCTYAI.png -white-threshold 70% result.png

Re: How to clean image and get only the signature

Posted: 2017-06-07T13:46:28-07:00
by filipemansano
fmw42 wrote: 2017-06-07T13:35:02-07:00 try

Code: Select all

convert GvCTYAI.png -white-threshold 70% result.png
Thanks!!
The function worked out, I did not use the value of 70% I used a value number of "10000" and solved

final code

Code: Select all

C:\imagick\bin\convert.exe ^
  teste.png ^
  -write mpr:ORG ^
  ( +clone ^
    -negate ^
    -morphology Erode rectangle:100x1 ^
    -mask mpr:ORG -morphology Dilate rectangle:100x1 ^
    +mask ^
  )^
  -compose CopyGreen -composite ^
  -normalize ^
  -fuzz 30000 -fill white -opaque "#47FF47" ^
  -fuzz 15000 -fill white -opaque "#FF00FF" ^
  -density 288 -antialias -sharpen 0x3.0 -colorspace GRAY ^
  -white-threshold 10000 ^
  out.png

Re: How to clean image and get only the signature

Posted: 2017-06-13T08:32:29-07:00
by filipemansano
How to remove content that is circled in red in the image below

http://imgur.com/a/H5H53

In the course of the tests appeared a case where it contains some words next to the signature, tried several ways with the morphoholgy remove, but all messed up the signature, would have a way to remove these letters without affecting the signature design?

Re: How to clean image and get only the signature

Posted: 2017-06-13T09:18:13-07:00
by fmw42
Post your image before you add the red. It interferes with a solution and is too hard to remove.

My suggestion is use -connected-componenets to remove small areas (the characters) and leave the one long signature. See http://magick.imagemagick.org/script/co ... onents.php

Code: Select all

convert P6gHiPG.png \
-define connected-components:verbose=true \
-define connected-components:area-threshold=150 \
-define connected-components:mean-color=true \
-connected-components 8 \
P6gHiPG_result.png
Image

Re: How to clean image and get only the signature

Posted: 2017-06-13T09:43:33-07:00
by filipemansano
Sorry, this image without red circle

(http://imgur.com/a/A4rgt)

I try to use the connected components option and I get an error
convert.exe: unrecognized option `-connected-components' @ error/convert.c/ConvertImageCommand/1156.

Version: ImageMagick 6.8.9-1 Q16 x64 2014-05-08

Re: How to clean image and get only the signature

Posted: 2017-06-13T09:47:38-07:00
by fmw42
Try my command with this latest image and it should create the same as my result, but without the red on the left edge

Re: How to clean image and get only the signature

Posted: 2017-06-13T09:58:42-07:00
by filipemansano
I tried but am getting an IM error alert, which version did you use to perform this command?

Re: How to clean image and get only the signature

Posted: 2017-06-13T10:07:08-07:00
by fmw42
IM 6.9.8.10 unix command. if on windows, try

Code: Select all

convert P6gHiPG.png ^
-define connected-components:verbose=true ^
-define connected-components:area-threshold=150 ^
-define connected-components:mean-color=true ^
-connected-components 8 ^
P6gHiPG_result.png
You need a version of ImageMagick that supports connected components. IM 6.8.9.10 or higher. So it looks like your 6.8.9.1 is a few versions too old. Can you upgrade?

Re: How to clean image and get only the signature

Posted: 2017-06-13T13:13:56-07:00
by filipemansano
Yes, I upgraded to the latest version
Thank you very much! It worked out

Re: How to clean image and get only the signature

Posted: 2018-07-23T01:49:56-07:00
by nextbars
Can you guys please help me, im trying to accomplish the same with php imagick library

Re: How to clean image and get only the signature

Posted: 2018-07-23T02:35:54-07:00
by snibgo
If this is a serious question, I suggest you consult IMagick documentation.