UP | HOME

# Anaglyph HALD Generator - Configuration Files and Control Parameters

By Oleg Kosyakovsky

## Table of Contents

- Configuration Files Format
- Control Parameters Specification

Colors in the generated HALD-CLUT are fully defined by control parameters passed to Anahald invocation in an Anahald configuration file.

Notes on glossary:

- the author uses interchangeably the terms "folder" and "directory"; the former is misleading but widely known , the latter is technically correct but for some reason "obstructed" from the common users
- the author uses interchangeably the terms "Tcl shell" and "Tcl interpreter"
- the author uses interchangeably the terms "command-shell* and "shell*; these refer to CMD or BASH
- "LUT" means lookup table, "CLUT" means color lookup table; the author uses these two terms and terms "HALD", "HALD-LUT", "HALD-CLUT" interchangeably
- "Identity-HALD" standardly means a HALD-CLUT that maps each color to itself
- the author refers to a HALD-CLUT made by Anaglyph HALD Generator as "balanced HALD"
- the author uses interchangeably the terms "configuration file", "config file", and "config"
- the author uses interchangeably the terms "anaglyph" and "red-cyan anaglyph"
- "balancing" a color means replacing it with some related anaglyph-friendly color obtained by reducing the difference between red channel on one side, and green and blue channels on the other side
- sides-ratio is a ratio between values of red channel, and maximum of green and blue channels - the larger divided by the smaller; used as a measure of disbalance in colors

## Configuration Files Format

Anahald configuration file contains a set of key=value pairs, where keys are names of control parameters (specs follow), and values are, well, their values. File format is that of commonly used .ini files where the key=value pairs are organized into sections.
Since the Anahald configuration file is utterly straightforward, an example with only a few explanations will suffice.
Here is a sample Anahald configuration file - "ahg_oleg_gp.ini" - one of the four supplied with Anahald:

    [Original_User_Specified]
    GreenToBlueBiasMultWhenMinor=1.0
    MaxBalancedMajorToMaxMinorRatio=2.0
    MaxRgbVal=255
    MinBndBalancedMajorToMaxMinorRatio=1.3
    MinMinorScaleOption=2
    PreInflateMinorToFract=1.0
    PreSqueezeMajorToFract=0.90
    SmoothBndBalancedOption=2
    [Secondary]
    LowPassFractionWhenMinor=0.00392156862745098
    LowPassThreshold=1
    MaxBalancedMajorToMinMinorRatio=6.0
    MinRgbVal=0
    ScaleBoudaryBalanced=1
    ZeroSubstRgbValForRatio=0.5

The syntax:

- a line with a string in brackets ([]) starts a section
  - only [Original_User_Specified] is of importance
    - do not alter anything in [Secondary] section
- there should be only one key-value pair in a line
- empty lines are permitted
- currently there's no support for comments
- there should be no whitespace between key, "=" sign, and value

That's all one needs to know about Anahald configuration file format.

## Control Parameters Specification

The detailed and comprehensive explanations on how each control parameter affects color computation is presented in Anahald_Algorithm_and_Parameters.html; this section summarizes the parameters while attempting to explain them from the usage viewpoint.

Here is the full list:

- GreenToBlueBiasMultWhenMinor - floating-point; range: [0.5 … 2.0]
  Defines color-shift on the minor (cyan) side in red-dominated colors
  - green channel is multiplied by 'GreenToBlueBiasMultWhenMinor'
  - blue channel is divided by 'GreenToBlueBiasMultWhenMinor'
  - (e.g. ''GreenToBlueBiasMultWhenMinor' < 1 results in blue cast)
- MaxBalancedMajorToMaxMinorRatio - floating-point; range: [1.0 … 6.0]
  Specifies the maximum sides-ratio for the color-trio (RGB) to be considered balanced
  - no color in the resulting LUT will have a bigger sides-ratio
  - the smaller 'MaxBalancedMajorToMaxMinorRatio', the stronger is the change in colors
  - for red-dominated colors, SidesRatio == R / max(G, B)
  - for cyan-dominated colors, SidesRatio == max(G, B) / R
- MaxRgbVal == 255 - a constant for now; meant for future extensions
- MinBndBalancedMajorToMaxMinorRatio; range: [1.0 … MaxBalancedMajorToMaxMinorRatio)
  Defines the lower bound of sides-ratio that could be affected while smoothening the boundary between balanced and unbalanced colors
  - colors with sides-ratio smaller than 'MinBndBalancedMajorToMaxMinorRatio' will not be altered for any purpose
  - 'MinBndBalancedMajorToMaxMinorRatio' must be strictly smaller than 'MaxBalancedMajorToMaxMinorRatio'
- MinMinorScaleOption - two possible values - 1 or 2
  Selects the formula used to balance the smaller (min-minor) of green and blue channels in red-dominated colors
  - for example if RGB=(100 30 10), red is major, green is max-minor, blue is min-minor
  - =1 -> min-minor channel balanced directly versus the red (major) channel
  - =2 -> relative-change of min-minor channel equals to relative-change of the max-minor channel
  - apparently, option "2" produces color tints closer to the original, but option "1" sometimes improves visibility of problematic objects
- PreInflateMinorToFract - floating-point; range: [0.5 … 1.0]
  If < 1.0, tells to increase the minor-side before further computations, so that the initial sides-ratio becomes 'PreInflateMinorToFract' of its original value
  - eventually forces the minor side of the resulting balanced color to be larger than it otherwise would
  - in a red-dominated color, green- and blue channels are scaled-up by the same factor; this factor is determined by the max-minor channel
- PreSqueezeMajorToFract - floating-point; range: [0.5 … 1.0]
  (symmetrical to PreInflateMinorToFract)
  If < 1.0, tells to decrease the major-side before further computations, so that the initial sides-ratio becomes 'PreSqueezeMajorToFract' of its original value
  - eventually forces the minor side of the resulting balanced color to be larger than it otherwise would
  - in a cyan-dominated color, green- and blue channels are scaled-down by the same factor; this factor is determined by the max-major channel
  - only one of PreInflateMinorToFract or PreSqueezeMajorToFract allowed to be active (e.g. < 1)
  - a tip on how to prevent nearly-red colors turning into pink or orange: make PreSqueezeMajorToFract relatively small, so that the balance is achieved by reducing red channel instead of bumping-up blue or green; visually the resulting color ends-up darker, but still appears to the eye as being red
- SmoothBndBalancedOption - two possible values - 1 or 2
  Selects the formula used to smoothen the boundary between originally-balanced and originally-unbalanced colors. Otherwise having the former preserved and the latter altered leaves color-gradients that cross this boundary with unwanted "stairs"
  - the originally-balanced colors applicable for the change have their sides-ratio between MinBndBalancedMajorToMaxMinorRatio and MaxBalancedMajorToMaxMinorRatio
    - such colors are referred to as marginally-balanced
  - the ultimate color-channel values will be weighted averages between their original values and the values they would receive if the color was treated as originally-unbalanced:
    - channelValueNew = (1 - w) * channelValueOld + w * channelValueIfScaled
      (0.0 <= w <= 1.0)
      amount of change starts with same-as-if-unbalabced (W=1) for colors with sides-ratio of MaxBalancedMajorToMaxMinorRatio, goes down with sides-ratiuo decreasing, and reaches zero (w=0) for colors with sides-ratio of MinBndBalancedMajorToMaxMinorRatio
  - the SmoothBndBalancedOption parameter defines how the weighting-factor (w) is calculated:
    - =1 -> "linear-smoothening" - the graph of weighting-factor depending on sides-ratio is a straight line from 1 at MaxBalancedMajorToMaxMinorRatio to 0 (zero) at MinBndBalancedMajorToMaxMinorRatio
    - =2 -> "parabolic-smoothening" - the graph of weighting-factor depending on sides-ratio is a half-parabola with the vertex (the maximum, upper point) of 1 at MaxBalancedMajorToMaxMinorRatio and touching 0 (zero) at MinBndBalancedMajorToMaxMinorRatio
    - "parabolic" option achieves smaller slope at the balanced-unbalanced boundary; this is a must when the range of marginally-balanced colors is rather narrow (MinBndBalancedMajorToMaxMinorRatio comes close to MaxBalancedMajorToMaxMinorRatio)
  - an alternative to smoothening the balanced-unbalanced boundary is to choose for each stereopair a LUT made with MaxBalancedMajorToMaxMinorRatio that doesn't create unwanted artifacts
    - in order to disable smoothening the boundary, set MinBndBalancedMajorToMaxMinorRatio == MaxBalancedMajorToMaxMinorRatio

Oleg Kosyakovsky

Haifa, Israel

2024-2025