Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
channelmixerrgb_shared.h File Reference
#include "pixel/chromatic_adaptation.h"
#include "develop/iop_profile.h"
#include <glib.h>
+ Include dependency graph for channelmixerrgb_shared.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_iop_channelmixer_shared_simple_params_t
 
struct  dt_iop_channelmixer_shared_primaries_params_t
 
struct  dt_iop_channelmixer_shared_white_preserving_params_t
 White-preserving primaries model : per-primary rotation and saturation, no white freedom. More...
 

Macros

#define DT_IOP_CHANNELMIXER_SHARED_SIMPLE_TAN_SCALE   1.55f
 
#define DT_IOP_CHANNELMIXER_SHARED_SIMPLE_EPS   5e-5f
 
#define DT_IOP_CHANNELMIXER_SHARED_SIMPLE_CHROMA_PROBE   0.5f
 
#define DT_IOP_CHANNELMIXER_SHARED_MIN_FOOTPRINT   0.02f
 

Typedefs

typedef struct _GtkWidget GtkWidget
 
typedef enum dt_iop_channelmixer_shared_primaries_basis_t dt_iop_channelmixer_shared_primaries_basis_t
 
typedef enum dt_iop_channelmixer_shared_simple_probe_t dt_iop_channelmixer_shared_simple_probe_t
 
typedef struct dt_iop_channelmixer_shared_simple_params_t dt_iop_channelmixer_shared_simple_params_t
 
typedef struct dt_iop_channelmixer_shared_primaries_params_t dt_iop_channelmixer_shared_primaries_params_t
 
typedef struct dt_iop_channelmixer_shared_white_preserving_params_t dt_iop_channelmixer_shared_white_preserving_params_t
 White-preserving primaries model : per-primary rotation and saturation, no white freedom.
 

Enumerations

enum  dt_iop_channelmixer_shared_primaries_basis_t {
  DT_IOP_CHANNELMIXER_SHARED_PRIMARIES_BASIS_RGB = 0 ,
  DT_IOP_CHANNELMIXER_SHARED_PRIMARIES_BASIS_XYZ = 1 ,
  DT_IOP_CHANNELMIXER_SHARED_PRIMARIES_BASIS_BRADFORD = 2 ,
  DT_IOP_CHANNELMIXER_SHARED_PRIMARIES_BASIS_CAT16 = 3
}
 
enum  dt_iop_channelmixer_shared_simple_probe_t {
  DT_IOP_CHANNELMIXER_SHARED_SIMPLE_PROBE_ROTATION = 0 ,
  DT_IOP_CHANNELMIXER_SHARED_SIMPLE_PROBE_AXIS_1 = 1 ,
  DT_IOP_CHANNELMIXER_SHARED_SIMPLE_PROBE_AXIS_2 = 2
}
 

Functions

float dt_iop_channelmixer_shared_wrap_pi (float angle)
 
float dt_iop_channelmixer_shared_wrap_half_pi (float angle)
 
float dt_iop_channelmixer_shared_encode_simple_stretch (float stretch)
 
float dt_iop_channelmixer_shared_decode_simple_stretch (float slider)
 
float dt_iop_channelmixer_shared_encode_simple_coupling_amount (float amount)
 
float dt_iop_channelmixer_shared_decode_simple_coupling_amount (float slider)
 
void dt_iop_channelmixer_shared_simple_from_sliders (GtkWidget *const widgets[6], dt_iop_channelmixer_shared_simple_params_t *simple)
 
void dt_iop_channelmixer_shared_simple_to_sliders (const dt_iop_channelmixer_shared_simple_params_t *simple, GtkWidget *const widgets[6])
 
void dt_iop_channelmixer_shared_primaries_from_sliders (GtkWidget *const widgets[9], dt_iop_channelmixer_shared_primaries_params_t *primaries)
 
void dt_iop_channelmixer_shared_primaries_to_sliders (const dt_iop_channelmixer_shared_primaries_params_t *primaries, GtkWidget *const widgets[9])
 
void dt_iop_channelmixer_shared_white_preserving_from_sliders (GtkWidget *const widgets[6], dt_iop_channelmixer_shared_white_preserving_params_t *white_preserving)
 
void dt_iop_channelmixer_shared_white_preserving_to_sliders (const dt_iop_channelmixer_shared_white_preserving_params_t *white_preserving, GtkWidget *const widgets[6])
 
gboolean dt_iop_channelmixer_shared_rows_are_normalized (const gboolean normalize[3])
 
gboolean dt_iop_channelmixer_shared_get_matrix (const float rows[3][3], const gboolean normalize[3], gboolean force_normalize, float M[3][3])
 
void dt_iop_channelmixer_shared_set_matrix (float rows[3][3], const float M[3][3])
 
void dt_iop_channelmixer_shared_mul3x3 (const float A[3][3], const float B[3][3], float C[3][3])
 
void dt_iop_channelmixer_shared_simple_from_matrix (const float M[3][3], dt_iop_channelmixer_shared_simple_params_t *simple)
 
void dt_iop_channelmixer_shared_simple_to_matrix (const dt_iop_channelmixer_shared_simple_params_t *simple, float M[3][3])
 
float dt_iop_channelmixer_shared_roundtrip_error (const float M[3][3], const float roundtrip[3][3])
 
float dt_iop_channelmixer_shared_roundtrip_error_relative (const float M[3][3], const float roundtrip[3][3])
 Roundtrip error, measured against the magnitude of the matrix itself.
 
dt_iop_channelmixer_shared_primaries_basis_t dt_iop_channelmixer_shared_primaries_basis_from_adaptation (dt_adaptation_t adaptation)
 
gboolean dt_iop_channelmixer_shared_primaries_to_matrix (dt_iop_channelmixer_shared_primaries_basis_t basis, const dt_iop_channelmixer_shared_primaries_params_t *primaries, float M[3][3])
 
gboolean dt_iop_channelmixer_shared_primaries_from_matrix (dt_iop_channelmixer_shared_primaries_basis_t basis, const float M[3][3], dt_iop_channelmixer_shared_primaries_params_t *primaries)
 
gboolean dt_iop_channelmixer_shared_white_preserving_to_matrix (dt_iop_channelmixer_shared_primaries_basis_t basis, const dt_iop_channelmixer_shared_white_preserving_params_t *white_preserving, float M[3][3])
 Build the mixer matrix of a white-preserving primaries state.
 
gboolean dt_iop_channelmixer_shared_white_preserving_from_matrix (dt_iop_channelmixer_shared_primaries_basis_t basis, const float M[3][3], dt_iop_channelmixer_shared_white_preserving_params_t *white_preserving)
 Read a white-preserving primaries state back from a mixer matrix.
 
void dt_iop_channelmixer_shared_simple_probe_source (dt_iop_channelmixer_shared_simple_probe_t probe, float source[3])
 
void dt_iop_channelmixer_shared_work_rgb_to_display (const dt_aligned_pixel_t work_rgb, const dt_iop_order_iccprofile_info_t *work_profile, const dt_iop_order_iccprofile_info_t *display_profile, dt_aligned_pixel_t display_rgb)
 
void dt_iop_channelmixer_shared_module_color_to_display (const float module_color[3], dt_adaptation_t adaptation, const dt_iop_order_iccprofile_info_t *work_profile, const dt_iop_order_iccprofile_info_t *display_profile, float display_rgb[3])
 
void dt_iop_channelmixer_shared_paint_temperature_slider (GtkWidget *widget, float temperature_min, float temperature_max)
 
void dt_iop_channelmixer_shared_paint_row_sliders (dt_adaptation_t adaptation, const dt_iop_order_iccprofile_info_t *work_profile, const dt_iop_order_iccprofile_info_t *display_profile, float r, float g, float b, gboolean normalize, const float row[3], GtkWidget *const widgets[3])
 
void dt_iop_channelmixer_shared_paint_simple_sliders (dt_adaptation_t adaptation, const dt_iop_order_iccprofile_info_t *work_profile, const dt_iop_order_iccprofile_info_t *display_profile, const dt_iop_channelmixer_shared_simple_params_t *simple, GtkWidget *const widgets[6])
 
void dt_iop_channelmixer_shared_paint_primaries_sliders (dt_adaptation_t adaptation, const dt_iop_order_iccprofile_info_t *work_profile, const dt_iop_order_iccprofile_info_t *display_profile, dt_iop_channelmixer_shared_primaries_basis_t basis, const dt_iop_channelmixer_shared_primaries_params_t *primaries, GtkWidget *const widgets[9])
 
void dt_iop_channelmixer_shared_paint_white_preserving_sliders (dt_adaptation_t adaptation, const dt_iop_order_iccprofile_info_t *work_profile, const dt_iop_order_iccprofile_info_t *display_profile, dt_iop_channelmixer_shared_primaries_basis_t basis, const dt_iop_channelmixer_shared_white_preserving_params_t *white_preserving, GtkWidget *const widgets[6])
 

Macro Definition Documentation

◆ DT_IOP_CHANNELMIXER_SHARED_MIN_FOOTPRINT

#define DT_IOP_CHANNELMIXER_SHARED_MIN_FOOTPRINT   0.02f

Definition at line 20 of file channelmixerrgb_shared.h.

◆ DT_IOP_CHANNELMIXER_SHARED_SIMPLE_CHROMA_PROBE

#define DT_IOP_CHANNELMIXER_SHARED_SIMPLE_CHROMA_PROBE   0.5f

Definition at line 17 of file channelmixerrgb_shared.h.

◆ DT_IOP_CHANNELMIXER_SHARED_SIMPLE_EPS

#define DT_IOP_CHANNELMIXER_SHARED_SIMPLE_EPS   5e-5f

Definition at line 16 of file channelmixerrgb_shared.h.

◆ DT_IOP_CHANNELMIXER_SHARED_SIMPLE_TAN_SCALE

#define DT_IOP_CHANNELMIXER_SHARED_SIMPLE_TAN_SCALE   1.55f

Definition at line 15 of file channelmixerrgb_shared.h.

Typedef Documentation

◆ dt_iop_channelmixer_shared_primaries_basis_t

◆ dt_iop_channelmixer_shared_primaries_params_t

◆ dt_iop_channelmixer_shared_simple_params_t

◆ dt_iop_channelmixer_shared_simple_probe_t

◆ dt_iop_channelmixer_shared_white_preserving_params_t

White-preserving primaries model : per-primary rotation and saturation, no white freedom.

Each primary is the chromaticity of one column of the mixer matrix, expressed in the affine plane of the current mixer basis. rotation turns it around the basis white, and saturation scales its distance to that white by 1 + saturation : -1 collapses the primary onto the white, 0 leaves it untouched, +1 doubles its distance. The three column magnitudes are then SOLVED, not chosen, so that the basis white maps to itself : that constraint is what removes the three remaining degrees of freedom of a 3x3 matrix, and is why six parameters describe the whole white-preserving submanifold exactly. All-zero parameters are the identity matrix, and a uniform saturation is the classic saturation matrix around the basis white.

◆ GtkWidget

typedef struct _GtkWidget GtkWidget

Definition at line 13 of file channelmixerrgb_shared.h.

Enumeration Type Documentation

◆ dt_iop_channelmixer_shared_primaries_basis_t

Enumerator
DT_IOP_CHANNELMIXER_SHARED_PRIMARIES_BASIS_RGB 
DT_IOP_CHANNELMIXER_SHARED_PRIMARIES_BASIS_XYZ 
DT_IOP_CHANNELMIXER_SHARED_PRIMARIES_BASIS_BRADFORD 
DT_IOP_CHANNELMIXER_SHARED_PRIMARIES_BASIS_CAT16 

Definition at line 22 of file channelmixerrgb_shared.h.

◆ dt_iop_channelmixer_shared_simple_probe_t

Enumerator
DT_IOP_CHANNELMIXER_SHARED_SIMPLE_PROBE_ROTATION 
DT_IOP_CHANNELMIXER_SHARED_SIMPLE_PROBE_AXIS_1 
DT_IOP_CHANNELMIXER_SHARED_SIMPLE_PROBE_AXIS_2 

Definition at line 30 of file channelmixerrgb_shared.h.

Function Documentation

◆ dt_iop_channelmixer_shared_decode_simple_coupling_amount()

float dt_iop_channelmixer_shared_decode_simple_coupling_amount ( float  slider)

◆ dt_iop_channelmixer_shared_decode_simple_stretch()

float dt_iop_channelmixer_shared_decode_simple_stretch ( float  slider)

◆ dt_iop_channelmixer_shared_encode_simple_coupling_amount()

float dt_iop_channelmixer_shared_encode_simple_coupling_amount ( float  amount)

◆ dt_iop_channelmixer_shared_encode_simple_stretch()

float dt_iop_channelmixer_shared_encode_simple_stretch ( float  stretch)

◆ dt_iop_channelmixer_shared_get_matrix()

gboolean dt_iop_channelmixer_shared_get_matrix ( const float  rows[3][3],
const gboolean  normalize[3],
gboolean  force_normalize,
float  M[3][3] 
)

◆ dt_iop_channelmixer_shared_module_color_to_display()

void dt_iop_channelmixer_shared_module_color_to_display ( const float  module_color[3],
dt_adaptation_t  adaptation,
const dt_iop_order_iccprofile_info_t work_profile,
const dt_iop_order_iccprofile_info_t display_profile,
float  display_rgb[3] 
)

◆ dt_iop_channelmixer_shared_mul3x3()

void dt_iop_channelmixer_shared_mul3x3 ( const float  A[3][3],
const float  B[3][3],
float  C[3][3] 
)

Definition at line 177 of file channelmixerrgb_shared.c.

References A, B, C, k, and row.

Referenced by _build_point_transform(), _mixer_from_chroma_basis(), and _mixer_to_chroma_basis().

◆ dt_iop_channelmixer_shared_paint_primaries_sliders()

◆ dt_iop_channelmixer_shared_paint_row_sliders()

void dt_iop_channelmixer_shared_paint_row_sliders ( dt_adaptation_t  adaptation,
const dt_iop_order_iccprofile_info_t work_profile,
const dt_iop_order_iccprofile_info_t display_profile,
float  r,
float  g,
float  b,
gboolean  normalize,
const float  row[3],
GtkWidget *const  widgets[3] 
)

◆ dt_iop_channelmixer_shared_paint_simple_sliders()

◆ dt_iop_channelmixer_shared_paint_temperature_slider()

void dt_iop_channelmixer_shared_paint_temperature_slider ( GtkWidget widget,
float  temperature_min,
float  temperature_max 
)

◆ dt_iop_channelmixer_shared_paint_white_preserving_sliders()

◆ dt_iop_channelmixer_shared_primaries_basis_from_adaptation()

◆ dt_iop_channelmixer_shared_primaries_from_matrix()

◆ dt_iop_channelmixer_shared_primaries_from_sliders()

◆ dt_iop_channelmixer_shared_primaries_to_matrix()

◆ dt_iop_channelmixer_shared_primaries_to_sliders()

◆ dt_iop_channelmixer_shared_roundtrip_error()

float dt_iop_channelmixer_shared_roundtrip_error ( const float  M[3][3],
const float  roundtrip[3][3] 
)

◆ dt_iop_channelmixer_shared_roundtrip_error_relative()

float dt_iop_channelmixer_shared_roundtrip_error_relative ( const float  M[3][3],
const float  roundtrip[3][3] 
)

Roundtrip error, measured against the magnitude of the matrix itself.

A reduced mixer model is a reparametrization, so the question its gate asks is whether the rebuilt matrix is the SAME matrix, which is a relative question. Comparing an absolute coefficient difference against a fixed tolerance silently demands more and more precision as the coefficients grow, and the white-preserving model can legitimately produce large ones : two primaries rotated onto the same ray make the chromaticity basis near-singular, which inflates the column scales that the white constraint solves for. The denominator is floored at 1 so ordinary, near-identity matrices keep the plain absolute behaviour.

Parameters
[in]MOriginal mixer matrix.
[in]roundtripMatrix rebuilt from the parameters read back from M.
Returns
Largest coefficient error, relative to the largest coefficient magnitude.

Definition at line 299 of file channelmixerrgb_shared.c.

References dt_iop_channelmixer_shared_roundtrip_error(), M, and row.

Referenced by _channelmixerrgb_sync_white_preserving_from_params(), and _sync_white_preserving_from_params().

◆ dt_iop_channelmixer_shared_rows_are_normalized()

gboolean dt_iop_channelmixer_shared_rows_are_normalized ( const gboolean  normalize[3])

◆ dt_iop_channelmixer_shared_set_matrix()

void dt_iop_channelmixer_shared_set_matrix ( float  rows[3][3],
const float  M[3][3] 
)

Definition at line 170 of file channelmixerrgb_shared.c.

References M, and row.

◆ dt_iop_channelmixer_shared_simple_from_matrix()

◆ dt_iop_channelmixer_shared_simple_from_sliders()

◆ dt_iop_channelmixer_shared_simple_probe_source()

◆ dt_iop_channelmixer_shared_simple_to_matrix()

◆ dt_iop_channelmixer_shared_simple_to_sliders()

◆ dt_iop_channelmixer_shared_white_preserving_from_matrix()

gboolean dt_iop_channelmixer_shared_white_preserving_from_matrix ( const dt_iop_channelmixer_shared_primaries_basis_t  basis,
const float  M[3][3],
dt_iop_channelmixer_shared_white_preserving_params_t white_preserving 
)

Read a white-preserving primaries state back from a mixer matrix.

Only the column DIRECTIONS are read here, so this succeeds for any matrix whose columns have a non-zero affine sum, white-preserving or not. Callers must gate on the roundtrip error against dt_iop_channelmixer_shared_white_preserving_to_matrix() to know whether the matrix actually sits on the white-preserving submanifold : a matrix that moves the white reconstructs to a different one, exactly like the other reduced mixer models.

Parameters
[in]basisAffine basis the mixer operates in, from the module's adaptation.
[in]MMixer matrix.
[out]white_preservingPer-primary rotations and saturations.
Returns
FALSE when a column has a null affine sum or the basis is degenerate.

Definition at line 784 of file channelmixerrgb_shared.c.

References _affine_normalize(), _build_affine_simplex(), _white_preserving_polar_from_point(), dt_iop_channelmixer_shared_white_preserving_params_t::blue_rotation, dt_iop_channelmixer_shared_white_preserving_params_t::blue_saturation, FALSE, dt_iop_channelmixer_shared_white_preserving_params_t::green_rotation, dt_iop_channelmixer_shared_white_preserving_params_t::green_saturation, M, dt_iop_channelmixer_shared_white_preserving_params_t::red_rotation, dt_iop_channelmixer_shared_white_preserving_params_t::red_saturation, and TRUE.

Referenced by _channelmixerrgb_sync_white_preserving_from_params(), and _sync_white_preserving_from_params().

◆ dt_iop_channelmixer_shared_white_preserving_from_sliders()

◆ dt_iop_channelmixer_shared_white_preserving_to_matrix()

gboolean dt_iop_channelmixer_shared_white_preserving_to_matrix ( const dt_iop_channelmixer_shared_primaries_basis_t  basis,
const dt_iop_channelmixer_shared_white_preserving_params_t *const  white_preserving,
float  M[3][3] 
)

Build the mixer matrix of a white-preserving primaries state.

The three rotated and rescaled chromaticities give the DIRECTION of each mixer column. Their magnitudes are then solved from the single constraint that the basis white maps to itself : with t = P^-1 . w (P holding the chromaticities in columns), column c of the matrix is t_c / w_c times chromaticity c, and M . w == w holds by construction.

Parameters
[in]basisAffine basis the mixer operates in, from the module's adaptation.
[in]white_preservingPer-primary rotations and saturations.
[out]MResulting mixer matrix.
Returns
FALSE when the displaced primaries are degenerate or the basis white has a null channel.

Definition at line 707 of file channelmixerrgb_shared.c.

References _affine_project_difference(), _affine_triangle_area(), _build_affine_simplex(), _primaries_reference_white(), _white_preserving_point_from_polar(), dt_iop_channelmixer_shared_white_preserving_params_t::blue_rotation, dt_iop_channelmixer_shared_white_preserving_params_t::blue_saturation, DT_IOP_CHANNELMIXER_SHARED_MIN_FOOTPRINT, DT_IOP_CHANNELMIXER_SHARED_SIMPLE_EPS, FALSE, dt_iop_channelmixer_shared_white_preserving_params_t::green_rotation, dt_iop_channelmixer_shared_white_preserving_params_t::green_saturation, M, mat3SSEinv(), dt_iop_channelmixer_shared_white_preserving_params_t::red_rotation, dt_iop_channelmixer_shared_white_preserving_params_t::red_saturation, row, and TRUE.

Referenced by _channelmixerrgb_sync_white_preserving_from_params(), _channelmixerrgb_white_preserving_slider_callback(), _sync_white_preserving_from_params(), _white_preserving_slider_callback(), and dt_iop_channelmixer_shared_paint_white_preserving_sliders().

◆ dt_iop_channelmixer_shared_white_preserving_to_sliders()

◆ dt_iop_channelmixer_shared_work_rgb_to_display()

◆ dt_iop_channelmixer_shared_wrap_half_pi()

float dt_iop_channelmixer_shared_wrap_half_pi ( float  angle)

◆ dt_iop_channelmixer_shared_wrap_pi()

float dt_iop_channelmixer_shared_wrap_pi ( float  angle)