Highpass Sharpen

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ithier

Highpass Sharpen

Post by ithier »

Hi,

I use GIMP and I have found a script from Martin Egger to sharpen an image using a highpass algorithm. The script is simple so I wanted to write it using Image Magick. I have written all the steps except the last one which is a composite overlay with an opacity of 50%.

The first steps, to generate the image to merge, are:
convert 05_0019.jpg -blur 0x10 etape1.png
convert etape1.png -negate etape2.png
composite -blend 50 etape2.png 05_0019.jpg etape3.png
convert etape3.png -level 25600,37800 etape4.png

Then the final steps: Overlay this generated image with the original image with an Opacity of 50%.
My first try was:
composite 05_0019.jpg etape4.png -compose Overlay etape5.png
The result is fine except that as there is no opacity defined the image is way too sharpened.

So I tried others methods:
Adding an alpha channel to etape4.png doesn't seems to work:
convert etape4.png -channel A -evaluate set 30% -format PNG32 etape4a.png
and then
composite 05_0019.jpg etape4a.png -compose Overlay etape5.png

I have also tried the following commands but with no result:
composite -blend 50 05_0019.jpg etape4.png -matte etape5.png
composite 05_0019.jpg -matte etape4.png -matte -dissolve 100x50 etape5.png

Does someone know how to reproduce the Opacity with 50% (or another percentage) function that I can find in GIMP.


Thanks in advance, and I hope you have understood my poor english.

Ithier
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Highpass Sharpen

Post by Bonzo »

You could try using

Code: Select all

composite -dissolve 50% 05_0019.jpg etape4a.png etape3.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Highpass Sharpen

Post by anthony »

You can even specifically use a negative percentage for Blend rather than dissolve.

See IM examples, http://imagemagick.org/Usage/compose/#blend_use
for Expratolation blending of images!!!!

PS: the operation you performed is known as 'unsharp' that is sharpening an image by subtracting the blurred form. IM also has the -unsharp operator that can do this directly
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ithier

Re: Highpass Sharpen

Post by ithier »

Hi,

Thanks Bonzo and Anthony for your answers. Unfortunately the result is not as close as what I can get with GIMP.
I have tried dissolve 50%, but it's lvery dimmed.
Antony I understand what you said about unsharp mask, but I would really like to implement this algorithm because simply, I prefer the result !! :)
For those interested, I made a gallery in Picasa with different settings.

If someone has an idea it will be greatly appreciated.

Ithier
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Highpass Sharpen

Post by fmw42 »

You can try my binomial script. It does something like this with a binomial filter rather than a gaussian. You can either sharpen or blur and control the mixing with the original image. My laplacian script does something similar but uses the laplacian as the high pass filter.

http://www.fmwconcepts.com/imagemagick/index.html
Post Reply