Author Topic: Bash HDR automation script(Hugin align_image_stack,enfuse,HDRmerge,FFmpeg)  (Read 670 times)

Danne

  • Hero Member
  • *****
  • Posts: 4530
license: GPL

HDR_CR2_JPG_TIF.command
Download:
https://bitbucket.org/Dannephoto/hdr_cr2_jpg_tif.command/downloads/HDR_CR2_JPG_TIF.command
Source:
https://bitbucket.org/Dannephoto/hdr_cr2_jpg_tif.command/overview

Lately I´ve been testing various ways of creating HDR images by creating an automated workflow which aims for minimal work from anybody running the script. It´s possible to process CR2, jpg and tif files bash menu.

How it works:

HDR_CR2_JPG_TIF.command will start by grouping files automated by checking the time gap between each photograph. Brackets will be sent to a "match" list which will be used for further processing(hugin align then sent to either enfuse or FFmpeg if not HDRmerge is used). If using CR2 files exiv2 will grab the included jpg thumbnail and work with those instead of with the CR2 fie. You can use jpg or tif files as well as starting point. When processing is done files created will be in tif format.

USAGE:
By downloading HDR_CR2_JPG_TIF.command  and double clicking it in a folder containing either CR2, jpg or tif files you simply need to choose something from the presented bash menu for further processing:


If programs are missing the script will ask the user if you want to install what´s missing
e.g:



Access permissions:
Make sure you are adding the correct access permissions to HDR_CR2_JPG_TIF.command:
In terminal write following and hit enter:
Code: [Select]
chmod u=rwx HDR_CR2_JPG_TIF.commandenter
Double clicking HDR_CR2_JPG_TIF.command should now work.

Copy paste:
The content in HDR_CR2_JPG_TIF.command can be pasted straight into terminal window to bypass any access permission issues. Make sure you are inside a folder containing files(CR2,jpg,tif).


Script breakdown:
The script is multiprocessing(up to 4 processes in parallell) and works with subscripts created on the fly when running HDR_CR2_JPG_TIF.command. When all is processed subscripts and other files will be cleaned from the folder the script is running from. Merged tif or dng files and files not processed as hdr files are what will be left inside your folder. Processed file originals files will be moved into A_ORIGINALS folder.

Programs used(dependencies):

align_image_stack(Hugin)
all preprocessing and will align files before merging.
http://macappstore.org/hugin/
Enfuse
to merge into tif files
HDRmerge
to process CR2 files into mergd dng files
http://jcelaya.github.io/hdrmerge/
FFmpeg
tblend averaging filter to create merged tif files
https://www.ffmpeg.org/
Exiv2
for extracting jpg preview files from CR2 files. Exiv2 is also constantly adding back original metadata from the CR2 file during processing.
http://www.exiv2.org/
Exiftool
https://www.sno.phy.queensu.ca/~phil/exiftool/
to fetch metadata in multiple places

Comparison between enfuse and FFmpeg(HDRmerge not included here):

Enfuse


FFmpeg


Enfuse


FFmpeg


Enfuse


FFmpeg


Enfuse
 

FFmpeg


Enfuse


FFmpeg




bouncyball

  • Hero Member
  • *****
  • Posts: 724
Re: Bash HDR automation script(Hugin align_image_stack,enfuse,HDRmerge,FFmpeg)
« Reply #1 on: February 26, 2018, 09:51:58 AM »
Enfuse versions are so live and pleasing to my eye! Recovered details are so great! I doubt ffmpeg ones can be processed (contrast, etc...) to match them.

Danne

  • Hero Member
  • *****
  • Posts: 4530
Re: Bash HDR automation script(Hugin align_image_stack,enfuse,HDRmerge,FFmpeg)
« Reply #2 on: February 26, 2018, 10:12:24 AM »
Yes, enfuse weighs pixels in more sophisticated ways but sometimes it do need some tweaking. Check whites in the window frame where the cat looks up for instance. Now it is not very easy understanding settings in enfuse. These are settings one could tweak in enfuse:

Code: [Select]
INPUT... are image filenames or response filenames.  Response
filenames start with an "@" character.

Options:
Common options:
  -l, --levels=LEVELS    limit number of blending LEVELS to use (1 to 29);
                         negative number of LEVELS decreases maximum;
                         "auto" restores the default automatic maximization
  -o, --output=FILE      write output to FILE; default: "a.tif"
  -v, --verbose[=LEVEL]  verbosely report progress; repeat to
                         increase verbosity or directly set to LEVEL
  --compression=COMPRESSION
                         set compression of output image to COMPRESSION,
                         where COMPRESSION is:
                         "deflate", "jpeg", "lzw", "none", "packbits", for TIFF files and
                         0 to 100, or "jpeg", "jpeg-arith" for JPEG files,
                         where "jpeg" and "jpeg-arith" accept a compression level

Advanced options:
  --blend-colorspace=COLORSPACE
                         force COLORSPACE for blending operations; Enfuse uses
                         "CIELUV" for images with ICC-profile and "IDENTITY" for
                         those without and also for all floating-point images;
                         other available blend color spaces are "CIELAB" and
                         "CIECAM"
  -c, --ciecam           use CIECAM02 to blend colors; disable with "--no-ciecam";
                         note that this option will be withdrawn in favor of
                         "--blend-colorspace"
  -d, --depth=DEPTH      set the number of bits per channel of the output
                         image, where DEPTH is "8", "16", "32", "r32", or "r64"
  -f WIDTHxHEIGHT[+xXOFFSET+yYOFFSET]
                         manually set the size and position of the output
                         image; useful for cropped and shifted input
                         TIFF images, such as those produced by Nona
  -g                     associated-alpha hack for Gimp (before version 2)
                         and Cinepaint
  -w, --wrap[=MODE]      wrap around image boundary, where MODE is "none",
                         "horizontal", "vertical", or "both"; default: none;
                         without argument the option selects horizontal wrapping

Fusion options:
  --exposure-weight=WEIGHT
                         weight given to well-exposed pixels
                         (0 <= WEIGHT <= 1); default: 1
  --saturation-weight=WEIGHT
                         weight given to highly-saturated pixels
                         (0 <= WEIGHT <= 1); default: 0.2
  --contrast-weight=WEIGHT
                         weight given to pixels in high-contrast neighborhoods
                         (0 <= WEIGHT <= 1); default: 0
  --entropy-weight=WEIGHT
                         weight given to pixels in high entropy neighborhoods
                         (0 <= WEIGHT <= 1); default: 0
  --exposure-optimum=OPTIMUM
                         optimum exposure value, usually the maximum of the weighting
                         function (0 <= OPTIMUM <= 1); default: 0.5
  --exposure-width=WIDTH
                         characteristic width of the weighting function
                         (WIDTH > 0); default: 0.2
  --soft-mask            average over all masks; this is the default
  --hard-mask            force hard blend masks and no averaging on finest
                         scale; this is especially useful for focus
                         stacks with thin and high contrast features,
                         but leads to increased noise

Expert options:
  --save-masks[=SOFT-TEMPLATE[:HARD-TEMPLATE]]
                         save weight masks in SOFT-TEMPLATE and HARD-TEMPLATE;
                         conversion chars: "%i": mask index, "%n": mask number,
                         "%p": full path, "%d": dirname, "%b": basename,
                         "%f": filename, "%e": extension; lowercase characters
                         refer to input images uppercase to the output image
                         default: "softmask-%n.tif":"hardmask-%n.tif"
  --load-masks[=SOFT-TEMPLATE[:HARD-TEMPLATE]]
                         skip calculation of weight maps and use the ones
                         in the files matching the templates instead.  These
                         can be either hard or soft masks.  For template
                         syntax see "--save-masks";
                         default: "softmask-%n.tif":"hardmask-%n.tif"
  --fallback-profile=PROFILE-FILE
                         use the ICC profile from PROFILE-FILE instead of sRGB
  --layer-selector=ALGORITHM
                         set the layer selector ALGORITHM;
                         default: "all-layers"; available algorithms are:
                         "all-layers": select all layers in any image;
                         "first-layer": select only first layer in each (multi-)layer image;
                         "last-layer": select only last layer in each (multi-)layer image;
                         "largest-layer": select largest layer in each (multi-)layer image;
                         "no-layer": do not select any layer from any image;
  --parameter=KEY1[=VALUE1][:KEY2[=VALUE2][:...]]
                         set one or more KEY-VALUE pairs

Expert fusion options:
  --exposure-weight-function=WEIGHT-FUNCTION    (1st form)
                         select one of the built-in exposure WEIGHT-FUNCTIONs:
                         "gaussian", "lorentzian", "half-sine", "full-sine",
                         or "bi-square"; default: "gaussian"
  --exposure-weight-function=SHARED-OBJECT:SYMBOL[:ARGUMENT[:...]]    (2nd form)
                         load user-defined exposure weight function SYMBOL
                         from SHARED-OBJECT and optionally pass ARGUMENTs
  --exposure-cutoff=LOWERCUTOFF[:UPPERCUTOFF[:LOWERPROJECTOR[:UPPERPROJECTOR]]]
                         LOWERCUTOFF and UPPERCUTOFF are the values below
                         or above of which pixels are weighted with zero
                         weight in exposure weighting; append "%" signs
                         for relative values; default: 0%:100%:anti-value:value
  --contrast-window-size=SIZE
                         set window SIZE for local-contrast analysis
                         (SIZE >= 3); default: 5
  --contrast-edge-scale=EDGESCALE[:LCESCALE[:LCEFACTOR]]
                         set scale on which to look for edges; positive
                         LCESCALE switches on local contrast enhancement
                         by LCEFACTOR (EDGESCALE, LCESCALE, LCEFACTOR >= 0);
                         append "%" to LCESCALE for values relative to
                         EDGESCALE; append "%" to LCEFACTOR for relative
                         value; default: 0:0:0
  --contrast-min-curvature=CURVATURE
                         minimum CURVATURE for an edge to qualify; append
                         "%" for relative values; default: 0
  --gray-projector=PROJECTOR
                         apply gray-scale PROJECTOR in exposure or contrast
                         weighing, where PROJECTOR is one of "anti-value",
                         "average", "l-star", "lightness", "luminance",
                         "pl-star", "value", or
                         "channel-mixer:RED-WEIGHT:GREEN-WEIGHT:BLUE-WEIGHT";
                         default: "average"
  --entropy-window-size=SIZE
                         set window SIZE for local entropy analysis
                         (SIZE >= 3); default: 3
  --entropy-cutoff=LOWERCUTOFF[:UPPERCUTOFF]
                         LOWERCUTOFF is the value below of which pixels are
                         treated as black and UPPERCUTOFF is the value above
                         of which pixels are treated as white in the entropy
                         weighting; append "%" signs for relative values;
                         default: 0%:100%

Information options:
  -h, --help             print this help message and exit
  -V, --version          output version information and exit
  --show-globbing-algorithms
                         show all globbing algorithms
  --show-image-formats   show all recognized image formats and their filename
                         extensions
  --show-signature       show who compiled the binary when and on which machine
  --show-software-components
                         show the software components with which Enfuse was compiled

Enfuse accepts arguments to any option in uppercase as
well as in lowercase letters.

Report bugs at <https://bugs.launchpad.net/enblend>.

bouncyball

  • Hero Member
  • *****
  • Posts: 724
Re: Bash HDR automation script(Hugin align_image_stack,enfuse,HDRmerge,FFmpeg)
« Reply #3 on: February 26, 2018, 12:00:07 PM »
Yeah... lot of options :)