Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
temperature.c File Reference
#include <assert.h>
#include <lcms2.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "bauhaus/bauhaus.h"
#include "common/colorspaces_inline_conversions.h"
#include "common/darktable.h"
#include "common/opencl.h"
#include "control/control.h"
#include "control/conf.h"
#include "develop/develop.h"
#include "develop/imageop_gui.h"
#include "develop/imageop_math.h"
#include "develop/tiling.h"
#include "dtgtk/expander.h"
#include "external/wb_presets.c"
#include "gui/gtk.h"
#include "gui/color_picker_proxy.h"
#include "iop/iop_api.h"
#include "common/colorspaces.h"
#include "external/cie_colorimetric_tables.c"
+ Include dependency graph for temperature.c:

Data Structures

struct  dt_iop_temperature_params_t
 
struct  dt_iop_temperature_gui_data_t
 
struct  dt_iop_temperature_data_t
 
struct  dt_iop_temperature_global_data_t
 
struct  dt_iop_temperature_preset_data_t
 

Macros

#define INITIALBLACKBODYTEMPERATURE   4000
 
#define DT_IOP_LOWEST_TEMPERATURE   1901
 
#define DT_IOP_HIGHEST_TEMPERATURE   25000
 
#define DT_IOP_LOWEST_TINT   0.135
 
#define DT_IOP_HIGHEST_TINT   2.326
 
#define DT_IOP_NUM_OF_STD_TEMP_PRESETS   4
 
#define DT_IOP_TEMP_AS_SHOT   0
 
#define DT_IOP_TEMP_SPOT   1
 
#define DT_IOP_TEMP_USER   2
 
#define DT_IOP_TEMP_D65   3
 
#define c1   3.7417715246641281639549488324352159753e-16L
 
#define c2   0.014387769599838156481252937624049081933L
 

Typedefs

typedef struct dt_iop_temperature_params_t dt_iop_temperature_params_t
 
typedef struct dt_iop_temperature_gui_data_t dt_iop_temperature_gui_data_t
 
typedef struct dt_iop_temperature_data_t dt_iop_temperature_data_t
 
typedef struct dt_iop_temperature_global_data_t dt_iop_temperature_global_data_t
 
typedef struct dt_iop_temperature_preset_data_t dt_iop_temperature_preset_data_t
 

Functions

static void gui_sliders_update (struct dt_iop_module_t *self)
 
int legacy_params (dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
 
static void _temp_params_from_array (dt_iop_temperature_params_t *p, const double a[4])
 
static void _temp_array_from_params (double a[4], const dt_iop_temperature_params_t *p)
 
static int ignore_missing_wb (dt_image_t *img)
 
const char * name ()
 
const char ** description (struct dt_iop_module_t *self)
 
int default_group ()
 
int flags ()
 
int default_colorspace (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
typedef double ((*spd)(unsigned long int wavelength, double TempK))
 
static double spd_blackbody (unsigned long int wavelength, double TempK)
 
static double spd_daylight (unsigned long int wavelength, double TempK)
 
static cmsCIEXYZ spectrum_to_XYZ (double TempK, spd I)
 
static cmsCIEXYZ temperature_to_XYZ (double TempK)
 
static cmsCIEXYZ temperature_tint_to_XYZ (double TempK, double tint)
 
static void XYZ_to_temperature (cmsCIEXYZ XYZ, float *TempK, float *tint)
 
static void xyz2mul (dt_iop_module_t *self, cmsCIEXYZ xyz, double mul[4])
 
static void temp2mul (dt_iop_module_t *self, double TempK, double tint, double mul[4])
 
static cmsCIEXYZ mul2xyz (dt_iop_module_t *self, const dt_iop_temperature_params_t *p)
 
static void mul2temp (dt_iop_module_t *self, dt_iop_temperature_params_t *p, float *TempK, float *tint)
 
static void dt_wb_preset_interpolate (const wb_data *const p1, const wb_data *const p2, wb_data *out)
 
static void scaled_copy_4wide (float *const outp, const float *const inp, const float *const coeffs)
 
void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
void commit_params (struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void init_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void cleanup_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
int generate_preset_combo (struct dt_iop_module_t *self)
 
void color_finetuning_slider (struct dt_iop_module_t *self)
 
void color_rgb_sliders (struct dt_iop_module_t *self)
 
void color_temptint_sliders (struct dt_iop_module_t *self)
 
void gui_update (struct dt_iop_module_t *self)
 
static int calculate_bogus_daylight_wb (dt_iop_module_t *module, double bwb[4])
 
static void prepare_matrices (dt_iop_module_t *module)
 
static void find_coeffs (dt_iop_module_t *module, double coeffs[4])
 
void reload_defaults (dt_iop_module_t *module)
 
void init_global (dt_iop_module_so_t *module)
 
void cleanup_global (dt_iop_module_so_t *module)
 
static void temp_tint_callback (GtkWidget *slider, dt_iop_module_t *self)
 
void gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 
static gboolean btn_toggled (GtkWidget *togglebutton, GdkEventButton *event, dt_iop_module_t *self)
 
static void preset_tune_callback (GtkWidget *widget, dt_iop_module_t *self)
 
void color_picker_apply (dt_iop_module_t *self, GtkWidget *picker, dt_dev_pixelpipe_iop_t *piece)
 
void gui_init (struct dt_iop_module_t *self)
 
void gui_cleanup (struct dt_iop_module_t *self)
 
void gui_reset (struct dt_iop_module_t *self)
 

Macro Definition Documentation

◆ c1

#define c1   3.7417715246641281639549488324352159753e-16L

◆ c2

#define c2   0.014387769599838156481252937624049081933L

◆ DT_IOP_HIGHEST_TEMPERATURE

#define DT_IOP_HIGHEST_TEMPERATURE   25000

◆ DT_IOP_HIGHEST_TINT

#define DT_IOP_HIGHEST_TINT   2.326

◆ DT_IOP_LOWEST_TEMPERATURE

#define DT_IOP_LOWEST_TEMPERATURE   1901

◆ DT_IOP_LOWEST_TINT

#define DT_IOP_LOWEST_TINT   0.135

◆ DT_IOP_NUM_OF_STD_TEMP_PRESETS

#define DT_IOP_NUM_OF_STD_TEMP_PRESETS   4

◆ DT_IOP_TEMP_AS_SHOT

#define DT_IOP_TEMP_AS_SHOT   0

◆ DT_IOP_TEMP_D65

#define DT_IOP_TEMP_D65   3

◆ DT_IOP_TEMP_SPOT

#define DT_IOP_TEMP_SPOT   1

◆ DT_IOP_TEMP_USER

#define DT_IOP_TEMP_USER   2

◆ INITIALBLACKBODYTEMPERATURE

#define INITIALBLACKBODYTEMPERATURE   4000

Typedef Documentation

◆ dt_iop_temperature_data_t

◆ dt_iop_temperature_global_data_t

◆ dt_iop_temperature_gui_data_t

◆ dt_iop_temperature_params_t

◆ dt_iop_temperature_preset_data_t

Function Documentation

◆ _temp_array_from_params()

static void _temp_array_from_params ( double  a[4],
const dt_iop_temperature_params_t p 
)
inlinestatic

◆ _temp_params_from_array()

static void _temp_params_from_array ( dt_iop_temperature_params_t p,
const double  a[4] 
)
inlinestatic

◆ btn_toggled()

static gboolean btn_toggled ( GtkWidget *  togglebutton,
GdkEventButton *  event,
dt_iop_module_t self 
)
static

◆ calculate_bogus_daylight_wb()

◆ cleanup_global()

◆ cleanup_pipe()

void cleanup_pipe ( struct dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

◆ color_finetuning_slider()

◆ color_picker_apply()

◆ color_rgb_sliders()

◆ color_temptint_sliders()

◆ commit_params()

◆ default_colorspace()

int default_colorspace ( dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

◆ default_group()

int default_group ( )

References IOP_GROUP_TECHNICAL.

◆ description()

const char ** description ( struct dt_iop_module_t self)

◆ double()

◆ dt_wb_preset_interpolate()

static void dt_wb_preset_interpolate ( const wb_data *const  p1,
const wb_data *const  p2,
wb_data *  out 
)
static

Referenced by gui_update(), and preset_tune_callback().

◆ find_coeffs()

◆ flags()

int flags ( )

◆ generate_preset_combo()

◆ gui_changed()

◆ gui_cleanup()

◆ gui_init()

◆ gui_reset()

◆ gui_sliders_update()

◆ gui_update()

◆ ignore_missing_wb()

static int ignore_missing_wb ( dt_image_t img)
static

◆ init_global()

◆ init_pipe()

◆ legacy_params()

int legacy_params ( dt_iop_module_t self,
const void *const  old_params,
const int  old_version,
void new_params,
const int  new_version 
)

◆ mul2temp()

static void mul2temp ( dt_iop_module_t self,
dt_iop_temperature_params_t p,
float *  TempK,
float *  tint 
)
static

◆ mul2xyz()

static cmsCIEXYZ mul2xyz ( dt_iop_module_t self,
const dt_iop_temperature_params_t p 
)
static

◆ name()

◆ prepare_matrices()

◆ preset_tune_callback()

◆ process()

◆ reload_defaults()

◆ scaled_copy_4wide()

static void scaled_copy_4wide ( float *const  outp,
const float *const  inp,
const float *const  coeffs 
)
inlinestatic

References for_four_channels.

Referenced by process().

◆ spd_blackbody()

static double spd_blackbody ( unsigned long int  wavelength,
double  TempK 
)
static

References c1, c2, and double().

Referenced by temperature_to_XYZ().

◆ spd_daylight()

static double spd_daylight ( unsigned long int  wavelength,
double  TempK 
)
static

References S.

Referenced by temperature_to_XYZ().

◆ spectrum_to_XYZ()

static cmsCIEXYZ spectrum_to_XYZ ( double  TempK,
spd  I 
)
static

References _max(), and P.

Referenced by temperature_to_XYZ().

◆ temp2mul()

static void temp2mul ( dt_iop_module_t self,
double  TempK,
double  tint,
double  mul[4] 
)
static
Todo:
: This is baaad!

TODO: problem here is that tint as it is is just a nasty hack modyfying Y component and therefore changing RGB coefficients in wrong way, because modifying only Y in that way doesn’t move XYZ point orthogonally to planckian locus. That means it actually changes temperature and thus it lies!

References temperature_to_XYZ(), and xyz2mul().

Referenced by color_temptint_sliders(), and temp_tint_callback().

◆ temp_tint_callback()

◆ temperature_tint_to_XYZ()

static cmsCIEXYZ temperature_tint_to_XYZ ( double  TempK,
double  tint 
)
static
Todo:
: This is baaad!

References temperature_to_XYZ().

Referenced by color_temptint_sliders().

◆ temperature_to_XYZ()

static cmsCIEXYZ temperature_to_XYZ ( double  TempK)
static

◆ xyz2mul()

static void xyz2mul ( dt_iop_module_t self,
cmsCIEXYZ  xyz,
double  mul[4] 
)
static

References dt_iop_module_t::gui_data.

Referenced by temp2mul().

◆ XYZ_to_temperature()

static void XYZ_to_temperature ( cmsCIEXYZ  XYZ,
float *  TempK,
float *  tint 
)
static
Todo:
: Fix this to move orthogonally to planckian locus

References DT_IOP_HIGHEST_TEMPERATURE, DT_IOP_HIGHEST_TINT, DT_IOP_LOWEST_TEMPERATURE, DT_IOP_LOWEST_TINT, and temperature_to_XYZ().

Referenced by mul2temp().