Page 1 of 2

Best Unsharp Mask settings after resizing photos

Posted: 2013-03-19T02:36:40-07:00
by davidb2002
Hi guys,

I'm resizing photos uploaded to a photography gallery and have thus applied an unsharp mask to attempt to perserve the photos original sharpness. The settings I use are:

radius: 0
sigma: 0.5
amount: 1
threshold: 0.05

I have noticed in some cases that photos are appearing over sharpened. Particularly when photos have high contrast close together lines.

So, what are the best settings for the unsharp mask after resizing? something I can apply to any photo uploaded and get the highest % of correctness. I understand that occasionally one won't look correct.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2013-03-19T07:59:07-07:00
by fmw42
I do not believe there is a "universal" set of values. It likely will depend upon the image detail and resize filter you use.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2013-03-19T08:27:42-07:00
by snibgo
I agree with fmw. In addition, where the original photo contains detail that can't be resolved in the web version, it can benefit from a small blurring before the resize and final sharpen.

Useful discussions of these matters on http://www.cambridgeincolour.com/ and http://www.luminous-landscape.com/index.shtml

Re: Best Unsharp Mask settings after resizing photos

Posted: 2013-03-19T09:08:03-07:00
by davidb2002
Understood. But what are the BEST settings to use when applying an unsharp mask to photos that have been resized?

Re: Best Unsharp Mask settings after resizing photos

Posted: 2013-03-19T09:57:08-07:00
by snibgo
You seem to have discovered for yourself that there is no "best" setting. Applying the same setting to all the photographs won't give the best results; some images will look over-sharpened, or some will look under-sharpened, or both.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2013-03-19T12:25:46-07:00
by fmw42
davidb2002 wrote:Understood. But what are the BEST settings to use when applying an unsharp mask to photos that have been resized?
I am not really sure that you do understand. There really is no such thing as BEST (or even any one recommended) setting for all images.

All that I can suggest is that you run a number of tests for the category of images you mostly use and go with what you like best.

But to help, the main arguments to deal with in -unsharp 0xsigma+gain+threshold is really only sigma. That controls the amount of sharpening. The gain should be 1 so that you add the sharpening equally to the image.

So really for simplicity take the defaults so that you use -unsharp 0xsigma. Note a sigma less than about 0.5 will produce nearly no change in the image. Larger sigma values will sharpen more. But if you get too large, then you will get artifacts. You can use the gain>1 to sharpen more for a given sigma. You can use the threshold to apply less sharpening, as the difference will need to pass a larger threshold before being added to the image.

Different -resize filters can affect the look of the image and mitigate ringing and moire. So different amounts of unsharp will be needed. The image content also comes into play as that can produce moire and ringing artifact when resized.

Edit:

For more information, please see
http://www.imagemagick.org/Usage/filter/
and especially
http://www.imagemagick.org/Usage/filter/nicolas/

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-14T22:38:54-07:00
by rossdv8
I have to use unsharp across a range of images at various resolutions. I had the same question as the OP, but after adjusting hundreds of images I'v settled on -unsharp 10x4+1+0 as being pretty universal.

But as has been mentioned above there is no real 'one size fits all' option. This is an old topic, but it is still relevant and I am surprised how few people realise what dramatic improvement can be made to improve an image using a simple Sigmoidal curve and an unsharp mask, before even considering other adjustments.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-15T12:02:36-07:00
by fmw42
ronaldphp wrote:+1 for -unsharp 10x4+1+0

I have started using this, and I think it works well for about 75% of my images that I process. The other 25% I just make fine adjustments to.
Normally one would let IM find the best radius for a given sigma which is usually about 2 or 3 times the sigma by using 0xsigma. If you make the radius too small for given sigma, you may not get reasonable results. If you make the radius too big, your processing time goes up.

The amount of sigma needed will likely be image size dependent. You may need a larger sigma for significantly larger images.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-15T12:14:42-07:00
by snibgo
For downsampling with sharpening, see the thread viewtopic.php?f=22&t=25935 and links from there.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-25T19:01:20-07:00
by rossdv8
Meanwhile, for anyone like me who just wants to enhance the detail in a few thousand images for printing on canvas (for example) try this. It is quick and dirty, and it works in Linux. Might need changes for Windows or Mac users.

All I need to do is get rid of the blur, especially from things like water, rigging on boats, trees, rocks and buildings in the distance. And I need to process maybe 20 to 100 photos at a time.

The script is annotated, but basically it should:
Rename all jpegs to lower case.
Strip any embedded icc profiles and rename the stripped files sequentially.
Apply a basic more or less generic (for me) unsharp to all photos in a folder.
Create an output folder.
Move all unsharped images into the output folder.
Clean up after itself.

On my computer it is modified to create a 'working' message inside the folder while it is running, then replaces it with a 'done' message when the job is complete. But I tend to process up to a hundred or more files at a time and I need to know what is happening. Most people probably don;t need to know.

Anyway, this forum has given me a lot. Perhaps someone else who just wants a quick sharpening of the detail in a heap of images will get some use from it.

It is messy script, and Fred, Anthony or snibgo can and possibly will probably write something much nicer. But for me - it works, so if anyone wants to try it - you're welcome.

Code: Select all

!#/bin/bash
# RossDV8's unsharp script for ImageMagick under Linux
# This strips the profile from every jpeg in a folder then applies basic unsharp
#  NOTE - DO This ONLY after ALL other corrections including HALD CLUT have been done
# What it should do is remove a lot of the blur in photos and make the image look more 3D(ish).

# RENAME all JPG to jpg
      #!/bin/sh
      # lowerit
      # convert all file names in the current directory to lower case
      # only operates on plain files--does not change the name of directories
      # will ask for verification before overwriting an existing file
      for x in `ls`
        do
        if [ ! -f $x ]; then
          continue
          fi
        lc=`echo $x  | tr '[A-Z]' '[a-z]'`
        if [ $lc != $x ]; then
          mv  $x $lc
        fi
        done
 
# Strip ICC profiles and rename numerically     
convert *.jpg +profile "*" 'noicc'$file.jpg
# Apply unsharp mask to all jpegs
convert 'noicc-'*.jpg  -unsharp 10x4+1+0 'unsharp'$file.jpg

# Make output folder
mkdir output

# move unsharped files to output
mv unsharp* output

# Clean Up
rm noicc*

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-25T19:21:26-07:00
by snibgo
Good stuff.

You do two converts, using the JPEG format for the intermediate file. I suggest you don't. (Each convert will decompress the image, then do a lossy compression. If the intermediate file is ".miff", the first lossy compression won't happen, and the script may be faster.)

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-25T22:50:30-07:00
by rossdv8
Thanks snibgo. Let me see if I have this right.

I should change:
# Strip ICC profiles and rename numerically
convert *.jpg +profile "*" 'noicc'$file.jpg
# Apply unsharp mask to all jpegs
convert 'noicc-'*.jpg -unsharp 10x4+1+0 'unsharp'$file.jpg

to read:
# Strip ICC profiles and rename numerically
convert *.jpg +profile "*" 'noicc'$file.miff
# Apply unsharp mask to all jpegs
convert 'noicc-'*.miff -unsharp 10x4+1+0 'unsharp'$file.jpg

Assuming that is correct, I'll try it. If it is correct, I'll repost the script with the bits that make the 'working' and 'done' display.

I just ran my original on a folder with 479 images downloaded from various web sites (yachting stuff) and mostly low res jpegs. I've really only used it on my own camera stuff before. But on the downloaded images the results are not just what I'm used to - they are startling.

Abraded bits on the halyards and sheets, and stainless steel that actually looks like a mirror.
All this time I never thought of using this on low res stuff I was posting to the web! I only did it for my canvas prints, and because the OP asked about it I thought I would share my stuff.

Anyway, I'll test your correction. Thanks again, snibgo.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-25T23:05:28-07:00
by rossdv8
Ok. I tried.

replacing .jpg with .miff did not work
likewise with .mif

So it looks like the original script is the go.

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-25T23:56:12-07:00
by snibgo
With .miff, IM will put all the images in a single file, instead of one jpeg file per image. So your second convert won't find any files named 'noicc-'*.jpg . There will be a single file named 'noicc'*.jpg (no hyphen).

Re: Best Unsharp Mask settings after resizing photos

Posted: 2014-10-26T06:28:28-07:00
by snibgo
On file formats generally, see http://www.imagemagick.org/script/formats.php

On MIFF specifically, see http://www.imagemagick.org/script/miff.php

MIFF is IM's own internal format, so reading and writing is quite fast. It can also store many images in one file.