How to "Smart Sharpen," adaptive-sharpen not working

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?".
ccreekin
Posts: 5
Joined: 2010-01-01T15:44:53-07:00
Authentication code: 8675309

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by ccreekin »

No Fred, I should try those scripts. Sharpedge has more of an effect on Lena's eyes (perhaps too much) and in some cases increases noise. Gaussianedge seems milder but still very noticeable. I am pleased with adaptive-sharpen, which is a big improvement over unsharp(mask). Adaptive seems to have wide latitude for different JPEG quality values.

The only downside is that -adaptive-shapen 0x0.1 produces ugly black splotches in my version of ImageMagick. But 0x0.6 made output files almost as small as did lesser values, so I settled on 0.6.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by anthony »

ccreekin wrote:Also radius does have an effect, although not the effect that I expected. I should take a look at the source code.
The effect or radius is to specify the actual 'kernel' size used for the blur/convolve. using a very large radius just makes this slower, using a small radius has the effect of 'clipping the kernel' whcih makes things worse. a radius of 0 produces the smallest radius (with a lower limit of 5) that contains a numerically significant Gaussian value. A large radius than this has no effect... period... a smaller value clips the kernel to some degree.

The only time a radius value has a non-detrimental effect is when you are attempting to use linear blurring effects, rather than Gaussian blurring. For example using a operation such as "-blur 5x65535". This produces a flat square kernel for blurring, producing a linear or triangular gradient on sharp edges about 11 pixels wide (5x2+1 - the kernel width).

However this technique can be improved by using Disk kernels with -morphology Convolve.
See IM Examples, Mean or Average Filtering using Shape Kernels
http://www.imagemagick.org/Usage/morphology/#mean

The -moprhology, and its ability to use a 'shaped kernel' was only added to IM since this discussion had previously lapsed.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
hwttdz
Posts: 22
Joined: 2010-08-29T05:29:08-07:00
Authentication code: 8675308

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by hwttdz »

I've just created a little perl script that does smart sharpening as described here: http://gimpguru.org/Tutorials/SmartSharpening2/
You can find the script as well as a short description here: http://astoryworthtelling.wordpress.com ... agemagick/

Please try different parameters and images, I tried it on a small selection of flickr explore images, and my personal images. And I think that it now gives either improvement or no change the majority of the time. But of course subject to personal tastes. It could possibly benefit from a curves adjust after the contrast stretch (done with linear stretch).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by fmw42 »

It could possibly benefit from a curves adjust after the contrast stretch (done with linear stretch).
try -gamma or -evaluate pow

or my curves script
hwttdz
Posts: 22
Joined: 2010-08-29T05:29:08-07:00
Authentication code: 8675308

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by hwttdz »

Fred,
I've posted some examples on the blog if you're interested (full size: http://www.flickr.com/photos/hwttdz/set ... 34/detail/ ). http://astoryworthtelling.wordpress.com ... agemagick/

Have you tried the script? I'd be interested to know what you think of the creation of the edge mask. But obviously getting best results would require the proper amount of sharpening in the sharpen layer, and a good edge mask.
-Joe
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by fmw42 »

Joe,

No I have not yet tried your script. Though I have had in mind to create one like it for a while. I had also seen that post from the GimpGuru. My other scripts (binomial edge, gaussianedge, and sharpedge) did similar things, but may have had too much sharpening because I simply thresholded the edge image to binary. The concept of using -level to fix the upper and lower edges, plus a gaussian blur makes sense.

Fred
3aHyga
Posts: 1
Joined: 2012-06-05T02:45:17-07:00
Authentication code: 13

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by 3aHyga »

fmw42 wrote:Have you tried my gaussedge or sharpedge scripts? Curious how they compare to adaptive-sharpen!
Hello,

Where can I found your scripts to test and use them?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by fmw42 »

3aHyga wrote:
fmw42 wrote:Have you tried my gaussedge or sharpedge scripts? Curious how they compare to adaptive-sharpen!
Hello,

Where can I found your scripts to test and use them?
See the link at the bottom of my post.
stupid
Posts: 51
Joined: 2010-02-12T07:30:34-07:00
Authentication code: 8675308

Re: How to "Smart Sharpen," adaptive-sharpen not working

Post by stupid »

Isn't "smart sharpen" the same as edge sharpening? If so try this.

INPUT.JPG ^
( +clone -unsharp 0x2 ) ^
( -clone 0 -separate -evaluate-sequence Mean -blur 0x2 -negate -edge 2 -level 0,50%% -blur 0x2 -level 0,50%% ) ^
-composite ^
OUTPUT.JPG


The -separate -evaluate-sequence Mean gives you the luminosity mask.

The line continuation characters "^" are for Windows in my example. Adjust yours accordingly.


s.
Post Reply