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. 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.

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.

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

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

As previous, plus auto-level

%IM%convert ^
  %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

%IM%convert ^
  %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

%IM%convert ^
  %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).

%IM%convert ^
  %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).

%IM%convert ^
  %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

%IM%convert ^
  %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

%IM%convert ^
  %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

%IM%convert ^
  %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

%IM%convert ^
  %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=\pictures\20130713\AGA_1372_sRGB.tiff

Prepare the source image

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

Apply the effect

%IM%convert ^
  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:

%IM%identify -version
Version: ImageMagick 6.9.5-3 Q16 x86 2016-07-22 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP 
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib

To improve internet download speeds, some images may have been automatically converted (by ImageMagick, of course) from PNG 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 04-Dec-2017 12:12:14.

Copyright © 2017 Alan Gibson.