snibgo's ImageMagick pages

Soft focus: spreading the light

A common effect, if over-used.

Soft focus is an effect used by photographers from the Victorians onwards, much used by David Hamilton in the 1970s, and still used in modern film and TV, and selfies on Facebook.

With analogue photography, the effect is created by a lens aberration, or a small smear of grease on the front or rear element or on a plain filter. The effect is to spread light so a proportion from bright parts of the object hit the wrong part of the film or sensor. The process is usually applied when the photograph is taken. If applied in the darkroom, when a negative is enlarged, it results in spreading of darkness instead of lightness.

It has minimal effect on light areas of the image, and greatest effect on dark areas. This creates a blur between light and dark in the image, lightening dark portions and eliminating small dark areas. This reduces or eliminates creases and moles in human skin, so tends to be flattering.

When the object is light against a dark background, the effect creates a halo around the object.

A side-effect of soft focus is that it lightens the image, lowering contrast and saturation, making colours more like pastels, adding to a dreamy or romantic mood. "-auto-level" reduces this effect.

Soft focus is a more subtle effect than out of focus.

(I'm not fond of this effect because I have cataracts so I get soft focus all the time. My eyes need all the contrast they can get.)

The method

We will demonstrate on the usual image:

set SRC=toes.png
toes.pngjpg

A single blade of grass is in front of the foot, near the small toe. If the examples, this grass more or less disappears.

There are many methods for obtaining the effect digitally. They all include a blur, either of all the colour channels, or just the Lightness.

Use the lighter of the image or a blur

set BLR_SIG=5

%IMG7%magick ^
  %SRC% ^
  ( +clone ^
    -blur 0x%BLR_SIG% ^
  ) ^
  -compose Lighten -composite ^
  sf_col1.png
sf_col1.pngjpg

As previous, plus auto-level

%IMG7%magick ^
  %SRC% ^
  ( +clone ^
    -blur 0x%BLR_SIG% ^
  ) ^
  -compose Lighten -composite ^
  -auto-level ^
  sf_col1a.png
sf_col1a.pngjpg

Use lightness to modulate between the image and a blur

set BLR_SIG=5

%IMG7%magick ^
  %SRC% ^
  ( -clone 0 ^
    -blur 0x%BLR_SIG% ^
  ) ^
  ( -clone 0 ^
    -colorspace Gray ^
    -negate ^
  ) ^
  -compose Over -composite ^
  sf_col3.png
sf_col3.pngjpg

As previous, plus auto-level

set BLR_SIG=5

%IMG7%magick ^
  %SRC% ^
  ( -clone 0 ^
    -blur 0x%BLR_SIG% ^
  ) ^
  ( -clone 0 ^
    -colorspace Gray ^
    -negate ^
  ) ^
  -compose Over -composite ^
  -auto-level ^
  sf_col3a.png
sf_col3a.pngjpg

Blur the L of Lab, without altering the other channels.

For the L of Lab, use the lighter of L and blur(L).

%IMG7%magick ^
  %SRC% ^
  -colorspace Lab ^
  -separate ^
  ( -clone 0 ^
    ( +clone ^
      -blur 0x%BLR_SIG% ^
    ) ^
    -compose Lighten -composite ^
  ) ^
  -swap 0,-1 ^
  +delete ^
  -combine ^
  -set colorspace Lab ^
  -colorspace sRGB ^
  sf_lab2.png
sf_lab2.pngjpg

Use L to modulate between L and blur(L).

%IMG7%magick ^
  %SRC% ^
  -colorspace Lab ^
  -separate ^
  ( -clone 0 ^
    ( -clone 0 ^
      -blur 0x%BLR_SIG% ^
    ) ^
    ( -clone 0 -negate ) ^
    -compose Over -composite ^
  ) ^
  -swap 0,-1 ^
  +delete ^
  -combine ^
  -set colorspace Lab ^
  -colorspace sRGB ^
  sf_lab3.png
sf_lab3.pngjpg

Interpolate or extrapolate.

Interpolate

%IMG7%magick ^
  %SRC% ^
  +write mpr:ORIG ^
  ( +clone ^
    -blur 0x%BLR_SIG% ^
  ) ^
  -compose Lighten -composite ^
  mpr:ORIG +swap ^
  -compose Blend ^
    -define compose:args=75 ^
    -composite ^
  sf_bl1.png
sf_bl1.pngjpg

Extrapolate

%IMG7%magick ^
  %SRC% ^
  +write mpr:ORIG ^
  ( +clone ^
    -blur 0x%BLR_SIG% ^
  ) ^
  -compose Lighten -composite ^
  mpr:ORIG +swap ^
  -compose Blend ^
    -define compose:args=150 ^
    -composite ^
  sf_bl2.png
sf_bl2.pngjpg

Soft focus reduces local contrast, so we may want to give that a boost, eg with "-unsharp".

Process all channels

set BLR_SIG=5
set SHP_SIG=1

%IMG7%magick ^
  %SRC% ^
  ( +clone ^
    -blur 0x%BLR_SIG% ^
  ) ^
  -compose Lighten -composite ^
  -auto-level ^
  -unsharp 0x%SHP_SIG% ^
  sf_col4.png
sf_col4.pngjpg

Process L of Lab

%IMG7%magick ^
  %SRC% ^
  -colorspace Lab ^
  -separate ^
  ( -clone 0 ^
    ( +clone ^
      -blur 0x%BLR_SIG% ^
    ) ^
    -compose Lighten -composite ^
    -auto-level ^
    -unsharp 0x%SHP_SIG% ^
    +write sf_bw.png ^
  ) ^
  -swap 0,-1 ^
  +delete ^
  -combine ^
  -set colorspace Lab ^
  -colorspace sRGB ^
  sf_white.png
sf_white.pngjpg

Applying one of those methods to a different image:

set SRC2=%PICTLIB%20130713\AGA_1372_sRGB.tiff

Prepare the source image

%IMG7%magick ^
  %SRC2% ^
  -crop 800x535+2803+2874 +repage ^
  -resize 600x600 ^
  -evaluate Pow 0.7 ^
  sf_1372.miff
sf_1372.miffjpg

Apply the effect

%IMG7%magick ^
  sf_1372.miff ^
  -colorspace Lab ^
  -separate ^
  ( -clone 0 ^
    ( +clone ^
      -blur 0x%BLR_SIG% ^
    ) ^
    -compose Lighten -composite ^
    -unsharp 0x%SHP_SIG% ^
    +write sf_bw.png ^
  ) ^
  -swap 0,-1 ^
  +delete ^
  -combine ^
  -set colorspace Lab ^
  -colorspace sRGB ^
  sf_1372_w.miff

call %PICTBAT%strLinear ^
  sf_1372_w.miff ^
  sf_1372_w.miff
sf_1372_w.miffjpg

The lightness channel makes a reasonable BW photo.

sf_bw.png

sf_bw.pngjpg

Freckles and moles have vanished, which is another reason it is often used in photos of young women.

For strLinear.bat, see Stretch linear.


All images on this page were created by the commands shown, using:

%IMG7%magick -version
Version: ImageMagick 7.1.0-42 Q16-HDRI x64 396d87c:20220709 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenCL 
Delegates (built-in): bzlib cairo freetype gslib heic jng jp2 jpeg jxl lcms lqr lzma openexr pangocairo png ps raqm raw rsvg tiff webp xml zip zlib
Compiler: Visual Studio 2022 (193231332)

To improve internet download speeds, some images may have been automatically converted (by ImageMagick, of course) from PNG or TIFF or MIFF to JPG.

Source file for this web page is softfoc.h1. To re-create this web page, execute "procH1 softfoc".


This page, including the images, is my copyright. Anyone is permitted to use or adapt any of the code, scripts or images for any purpose, including commercial use.

Anyone is permitted to re-publish this page, but only for non-commercial use.

Anyone is permitted to link to this page, including for commercial use.


Page version v1.0 19-November-2017.

Page created 08-Aug-2022 22:48:57.

Copyright © 2022 Alan Gibson.