fabien van mook

all packages "fvm-*"

package "fvm-colourgrade"

function file "colourgrade_offset.m"

Function cg = colourgrade_offset(cg)

returns the input struct cg after setting
cg.offset based on given cg.gradevalues
and cg.offsetthreshold. In the process,
  cg.gradevalues
  cg.gradeticks
  cg.gradetexts
may be adapted as well; see below.

If for an index k
  cg.gradevalues(k:end) >= cg.offsetthreshold,
then cg.offset is set to (k-1). In this case,
the values in cg.gradevalues are shifted by
(cg.gradevalues(k)-cg.offsetthreshold), an
grade interval is appended to it, and 
cg.gradeticks and cg.gradetexts are set to
empty arrays. The latter two arrays can be 
regenerated by colourgrade_bluered.m (intended)
or colourgrade_init.m.

If 
  cg.gradevalues(1:end) >= cg.offsetthreshold,
then cg.offset is set to 0.

If 
  cg.gradevalues(1:end) < cg.offsetthreshold,
then cg.offset is set to (length(cg.gradevalues) - 1).

At input, the struct cg must have the following
fields:
  cg.gradevalues     (column vector of reals)
  cg.offsetthreshold (scalar)

At output, the struc cg contains new or renewed
fields:
  cg.gradevalues (column vector of reals)
  cg.gradeticks  (column vector of booleans)
  cg.gradetexts  (column cell-array of strings)
  cg.offset      (cg.icm_min + cg.offset is the
                  row index to the colourmap
                  where the second part starts)


(c) 2026 fabien van mook

2026.08.20 release of this file within package "fvm-colourgrade" under GNU GPLv3+