![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "widgets/label.h"#include "widgets/bauhaus.h"#include "system/target_clones.h"#include "system/mem_alloc.h"#include "common/module_versioning.h"#include "metadata/exif.h"#include "develop/blend.h"#include "develop/imageop.h"#include "develop/imageop_math.h"#include "develop/imageop_gui.h"#include "gui/presets.h"#include "gui/color_picker_proxy.h"#include "iop/iop_api.h"#include <stdlib.h>#include "control/signal.h"
Include dependency graph for colorbalance.c:Go to the source code of this file.
Data Structures | |
| struct | dt_iop_colorbalance_params_t |
| struct | dt_iop_colorbalance_gui_data_t |
| struct | dt_iop_colorbalance_data_t |
| struct | dt_iop_colorbalance_global_data_t |
Macros | |
| #define | HSL_CALLBACK(which) |
| #define | ADD_CHANNEL(which, section, c, n, N, text, span) |
| #define | ADD_BLOCK(blk, which, section, text, span, satspan) |
Typedefs | |
| typedef enum dt_iop_colorbalance_mode_t | dt_iop_colorbalance_mode_t |
| typedef enum _colorbalance_channel_t | _colorbalance_channel_t |
| typedef enum _colorbalance_levels_t | _colorbalance_levels_t |
| typedef enum _controls_t | _controls_t |
| typedef enum _colorbalance_patch_t | _colorbalance_patch_t |
| typedef struct dt_iop_colorbalance_params_t | dt_iop_colorbalance_params_t |
| typedef struct dt_iop_colorbalance_gui_data_t | dt_iop_colorbalance_gui_data_t |
| typedef struct dt_iop_colorbalance_data_t | dt_iop_colorbalance_data_t |
| typedef struct dt_iop_colorbalance_global_data_t | dt_iop_colorbalance_global_data_t |
Enumerations | |
| enum | dt_iop_colorbalance_mode_t { LIFT_GAMMA_GAIN = 0 , SLOPE_OFFSET_POWER = 1 , LEGACY = 2 } |
| enum | _colorbalance_channel_t { CHANNEL_FACTOR = 0 , CHANNEL_RED , CHANNEL_GREEN , CHANNEL_BLUE , CHANNEL_SIZE } |
| enum | _colorbalance_levels_t { LIFT = 0 , GAMMA , GAIN , LEVELS } |
| enum | _controls_t { HSL , RGBL , BOTH } |
| enum | _colorbalance_patch_t { INVALID , USER_SELECTED , AUTO_SELECTED } |
| #define ADD_BLOCK | ( | blk, | |
| which, | |||
| section, | |||
| text, | |||
| span, | |||
| satspan | |||
| ) |
| #define HSL_CALLBACK | ( | which | ) |
Definition at line 1553 of file colorbalance.c.
| typedef enum _colorbalance_channel_t _colorbalance_channel_t |
| typedef enum _colorbalance_levels_t _colorbalance_levels_t |
| typedef enum _colorbalance_patch_t _colorbalance_patch_t |
| typedef enum _controls_t _controls_t |
| typedef struct dt_iop_colorbalance_data_t dt_iop_colorbalance_data_t |
| typedef struct dt_iop_colorbalance_gui_data_t dt_iop_colorbalance_gui_data_t |
| typedef enum dt_iop_colorbalance_mode_t dt_iop_colorbalance_mode_t |
| typedef struct dt_iop_colorbalance_params_t dt_iop_colorbalance_params_t |
| Enumerator | |
|---|---|
| CHANNEL_FACTOR | |
| CHANNEL_RED | |
| CHANNEL_GREEN | |
| CHANNEL_BLUE | |
| CHANNEL_SIZE | |
Definition at line 96 of file colorbalance.c.
| Enumerator | |
|---|---|
| LIFT | |
| GAMMA | |
| GAIN | |
| LEVELS | |
Definition at line 105 of file colorbalance.c.
| Enumerator | |
|---|---|
| INVALID | |
| USER_SELECTED | |
| AUTO_SELECTED | |
Definition at line 120 of file colorbalance.c.
| enum _controls_t |
| Enumerator | |
|---|---|
| HSL | |
| RGBL | |
| BOTH | |
Definition at line 113 of file colorbalance.c.
| Enumerator | |
|---|---|
| LIFT_GAMMA_GAIN | |
| SLOPE_OFFSET_POWER | |
| LEGACY | |
Definition at line 89 of file colorbalance.c.
|
inlinestatic |
Definition at line 725 of file colorbalance.c.
References dt_bauhaus_widget_set_label(), dt_iop_gui_data(), g, GAIN, GAMMA, LIFT, and USER_SELECTED.
Referenced by color_picker_apply(), gui_reset(), and gui_update().
|
static |
Definition at line 1503 of file colorbalance.c.
References dt_conf_get_string(), dt_free, DT_GUI_BOX_SPACING, dt_iop_gui_data(), dt_ui_section_label_new(), g, and i.
Referenced by _cycle_layout_callback(), gui_changed(), gui_cleanup(), and gui_init().
|
static |
Definition at line 1548 of file colorbalance.c.
References _configure_slider_blocks().
Referenced by gui_init().
|
static |
Definition at line 277 of file colorbalance.c.
References dt_develop_blend_legacy_params_from_so(), dt_develop_blend_version(), dt_exif_xmp_decode(), dt_free, dt_gui_presets_add_with_blendop(), name(), dt_iop_module_so_t::op, and p.
Referenced by _ioporder_init_popup(), and init_presets().
| const char * aliases | ( | ) |
Definition at line 182 of file colorbalance.c.
|
static |
Optimization loop : We try to find the CDL curves that neutralize the 3 input color patches, while not affecting the overall lightness. But this is a non-linear overconstrained problem with tainted inputs, so the best we can do is a numerical optimization. To do so, we compute each parameter of each RGB curve from the input color and the 2 other parameters. Then, we loop over the previous optimization until the difference between 2 updates is insignificant. This would need a proper stopping criterion based on convergence analysis, but it would be overkill here since it should converge usually in 20 iterations, and maximum in 100. Also, the convergence has not been proven formally. For better color accuracy, we compute on luminance corrected RGB values (after the main factors corrections). To avoid divergence, we constrain the parameters between +- 0.25 around the neutral value. Experimentally, nothing good happens out of these bounds.
Definition at line 972 of file colorbalance.c.
References AUTO_SELECTED, CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_iop_color_picker_reset(), dt_iop_gui_data(), dt_Lab_to_XYZ(), dt_prophotorgb_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAIN, GAMMA, INVALID, LIFT, MAX, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, RGB, set_HSL_sliders(), TRUE, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 743 of file colorbalance.c.
References CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_gui_widgets_suppressed(), dt_iop_gui_data(), dt_Lab_to_XYZ(), dt_prophotorgb_to_XYZ(), dt_XYZ_to_prophotorgb(), g, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, rgb, TRUE, and XYZ.
Referenced by color_picker_apply().
|
static |
Optimization loop : We try to find the CDL curves that neutralize the 3 input luma patches
Definition at line 1090 of file colorbalance.c.
References AUTO_SELECTED, CHANNEL_FACTOR, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_iop_color_picker_reset(), dt_iop_gui_data(), dt_Lab_to_XYZ(), g, GAIN, GAMMA, INVALID, LIFT, MAX, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, dt_iop_module_t::picked_color_max, dt_iop_module_t::picked_color_min, TRUE, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 948 of file colorbalance.c.
References CHANNEL_FACTOR, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_gui_widgets_suppressed(), dt_iop_gui_data(), dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAIN, p, dt_iop_module_t::params, dt_iop_module_t::picked_color_max, RGB, TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 860 of file colorbalance.c.
References CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_gui_widgets_suppressed(), dt_iop_gui_data(), dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAIN, MAX, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, RGB, set_HSL_sliders(), TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 923 of file colorbalance.c.
References CHANNEL_FACTOR, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_gui_widgets_suppressed(), dt_iop_gui_data(), dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAMMA, MAX, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, RGB, TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 821 of file colorbalance.c.
References CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_gui_widgets_suppressed(), dt_iop_gui_data(), dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAMMA, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, RGB, set_HSL_sliders(), TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 899 of file colorbalance.c.
References CHANNEL_FACTOR, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_gui_widgets_suppressed(), dt_iop_gui_data(), dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, LIFT, p, dt_iop_module_t::params, dt_iop_module_t::picked_color_min, RGB, TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 782 of file colorbalance.c.
References CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, dt_iop_module_t::dev, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_gui_freeze_begin, dt_gui_freeze_end, dt_gui_widgets_suppressed(), dt_iop_gui_data(), dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, LIFT, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, RGB, set_HSL_sliders(), TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
inlinestatic |
Definition at line 336 of file colorbalance.c.
Referenced by apply_autocolor(), apply_autogrey(), apply_gain_neutralize(), apply_gamma_neutralize(), apply_lift_neutralize(), and process().
| void cleanup_global | ( | dt_iop_module_so_t * | module | ) |
| void cleanup_pipe | ( | dt_iop_module_t * | self, |
| dt_dev_pixelpipe_t * | pipe, | ||
| dt_dev_pixelpipe_iop_t * | piece | ||
| ) |
Definition at line 1281 of file colorbalance.c.
References dt_dev_pixelpipe_iop_t::data, and dt_free_align.
| void color_picker_apply | ( | dt_iop_module_t * | self, |
| GtkWidget * | picker, | ||
| dt_dev_pixelpipe_t * | pipe, | ||
| dt_dev_pixelpipe_iop_t * | piece | ||
| ) |
Definition at line 1142 of file colorbalance.c.
References _check_tuner_picker_labels(), apply_autocolor(), apply_autogrey(), apply_autoluma(), apply_gain_auto(), apply_gain_neutralize(), apply_gamma_auto(), apply_gamma_neutralize(), apply_lift_auto(), apply_lift_neutralize(), dt_iop_gui_data(), and g.
| 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 | ||
| ) |
Definition at line 1189 of file colorbalance.c.
References CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, CHANNEL_SIZE, d, dt_dev_pixelpipe_iop_t::data, dt_prophotorgb_to_XYZ(), i, LEGACY, LIFT_GAMMA_GAIN, dt_iop_colorbalance_params_t::mode, p, SLOPE_OFFSET_POWER, and XYZ.
|
static |
Definition at line 1371 of file colorbalance.c.
References dt_gui_widgets_suppressed(), dt_iop_color_picker_reset(), dt_iop_gui_data(), g, set_visible_widgets(), and TRUE.
Referenced by gui_init().
| int default_colorspace | ( | dt_iop_module_t * | self, |
| dt_dev_pixelpipe_t * | pipe, | ||
| const dt_dev_pixelpipe_iop_t * | piece | ||
| ) |
Definition at line 206 of file colorbalance.c.
References IOP_CS_LAB.
| int default_group | ( | ) |
Definition at line 201 of file colorbalance.c.
References IOP_GROUP_COLOR.
| const char ** description | ( | struct dt_iop_module_t * | self | ) |
Definition at line 187 of file colorbalance.c.
References dt_iop_set_description().
| int flags | ( | ) |
Definition at line 196 of file colorbalance.c.
References IOP_FLAGS_DEPRECATED, IOP_FLAGS_INCLUDE_IN_STYLES, and IOP_FLAGS_SUPPORTS_BLENDING.
Definition at line 1576 of file colorbalance.c.
Definition at line 1575 of file colorbalance.c.
| void gui_changed | ( | dt_iop_module_t * | self, |
| GtkWidget * | w, | ||
| void * | previous | ||
| ) |
Definition at line 1348 of file colorbalance.c.
References _configure_slider_blocks(), dt_gui_freeze_begin, dt_gui_freeze_end, dt_iop_gui_data(), g, IS_NULL_PTR, p, dt_iop_module_t::params, set_HSL_sliders(), and set_visible_widgets().
Referenced by gui_update().
| void gui_cleanup | ( | struct dt_iop_module_t * | self | ) |
Definition at line 1817 of file colorbalance.c.
References _configure_slider_blocks(), dt_control_signal_get_global(), DT_DEBUG_CONTROL_SIGNAL_DISCONNECT, and IOP_GUI_FREE.
| void gui_init | ( | dt_iop_module_t * | self | ) |
Definition at line 1578 of file colorbalance.c.
References _configure_slider_blocks(), _cycle_layout_callback(), ADD_BLOCK, BOTH, controls_callback(), dt_bauhaus_combobox_add(), dt_bauhaus_combobox_from_params(), dt_bauhaus_combobox_new(), dt_bauhaus_combobox_set(), dt_bauhaus_get_global(), dt_bauhaus_slider_from_params(), dt_bauhaus_slider_set_digits(), dt_bauhaus_slider_set_factor(), dt_bauhaus_slider_set_format(), dt_bauhaus_slider_set_offset(), dt_bauhaus_slider_set_soft_range(), dt_bauhaus_widget_set_label(), DT_COLOR_PICKER_AREA, dt_color_picker_new(), dt_conf_get_string_const(), dt_control_signal_get_global(), DT_DEBUG_CONTROL_SIGNAL_CONNECT, DT_GUI_BOX_SPACING, DT_GUI_MODULE, DT_SIGNAL_PREFERENCES_CHANGE, dt_ui_section_label_new(), dtgtk_drawing_area_new_with_aspect_ratio(), FALSE, g, HSL, INVALID, IOP_GUI_ALLOC, k, LEVELS, RGBL, and TRUE.
| void gui_reset | ( | dt_iop_module_t * | self | ) |
Definition at line 1328 of file colorbalance.c.
References _check_tuner_picker_labels(), dt_bauhaus_combobox_set(), dt_iop_color_picker_reset(), dt_iop_gui_data(), g, HSL, INVALID, k, LEVELS, set_visible_widgets(), and TRUE.
| void gui_update | ( | dt_iop_module_t * | self | ) |
Definition at line 1320 of file colorbalance.c.
References _check_tuner_picker_labels(), dt_iop_color_picker_reset(), gui_changed(), and TRUE.
| void init_global | ( | dt_iop_module_so_t * | module | ) |
| void init_pipe | ( | dt_iop_module_t * | self, |
| dt_dev_pixelpipe_t * | pipe, | ||
| dt_dev_pixelpipe_iop_t * | piece | ||
| ) |
Definition at line 1275 of file colorbalance.c.
References dt_dev_pixelpipe_iop_t::data, dt_dev_pixelpipe_iop_t::data_size, and dt_calloc_align().
| void init_presets | ( | dt_iop_module_so_t * | self | ) |
Definition at line 309 of file colorbalance.c.
References add_preset().
| void input_format | ( | dt_iop_module_t * | self, |
| dt_dev_pixelpipe_t * | pipe, | ||
| dt_dev_pixelpipe_iop_t * | piece, | ||
| dt_iop_buffer_dsc_t * | dsc | ||
| ) |
Definition at line 211 of file colorbalance.c.
References dt_iop_buffer_dsc_t::channels, dt_iop_buffer_dsc_t::datatype, default_input_format(), and TYPE_FLOAT.
| int legacy_params | ( | dt_iop_module_t * | self, |
| const void *const | old_params, | ||
| const int | old_version, | ||
| void * | new_params, | ||
| const int | new_version | ||
| ) |
Definition at line 219 of file colorbalance.c.
References CHANNEL_SIZE, d, dt_iop_module_t::default_params, i, LEGACY, and n.
Definition at line 1574 of file colorbalance.c.
| const char * name | ( | ) |
Definition at line 177 of file colorbalance.c.
Referenced by add_preset().
| __DT_CLONE_TARGETS__ int process | ( | struct dt_iop_module_t * | self, |
| const dt_dev_pixelpipe_t * | pipe, | ||
| const dt_dev_pixelpipe_iop_t * | piece, | ||
| const void *const | ivoid, | ||
| void *const | ovoid | ||
| ) |
Definition at line 346 of file colorbalance.c.
References __OMP_PARALLEL_FOR_SIMD__, CDL(), ch, CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, d, dt_dev_pixelpipe_iop_t::data, DT_DEV_PIXELPIPE_DISPLAY_MASK, dt_Lab_to_XYZ(), dt_prophotorgb_to_XYZ(), dt_XYZ_to_Lab(), dt_XYZ_to_prophotorgb(), dt_XYZ_to_sRGB(), dt_iop_roi_t::height, k, LEGACY, LIFT_GAMMA_GAIN, dt_dev_pixelpipe_t::mask_display, out, ovoid, rgb, dt_dev_pixelpipe_iop_t::roi_in, dt_dev_pixelpipe_iop_t::roi_out, SLOPE_OFFSET_POWER, dt_iop_roi_t::width, and XYZ.
| int process_cl | ( | struct dt_iop_module_t * | self, |
| const dt_dev_pixelpipe_t * | pipe, | ||
| const dt_dev_pixelpipe_iop_t * | piece, | ||
| cl_mem | dev_in, | ||
| cl_mem | dev_out | ||
| ) |
Definition at line 538 of file colorbalance.c.
References CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, d, dt_dev_pixelpipe_iop_t::data, dt_dev_pixelpipe_t::devid, DT_DEBUG_OPENCL, dt_opencl_enqueue_kernel_2d(), dt_opencl_set_kernel_arg(), dt_print(), error(), FALSE, dt_iop_module_t::global_data, height, dt_iop_roi_t::height, dt_iop_colorbalance_global_data_t::kernel_colorbalance, dt_iop_colorbalance_global_data_t::kernel_colorbalance_cdl, dt_iop_colorbalance_global_data_t::kernel_colorbalance_lgg, LEGACY, LIFT_GAMMA_GAIN, dt_dev_pixelpipe_iop_t::roi_in, ROUNDUPDHT, ROUNDUPDWD, SLOPE_OFFSET_POWER, TRUE, width, and dt_iop_roi_t::width.
HSL sliders are set from the RGB values at any time. Only the RGB values are saved and used in the computations. The HSL sliders are merely an interface.
Definition at line 699 of file colorbalance.c.
References CHANNEL_BLUE, CHANNEL_GREEN, CHANNEL_RED, dt_bauhaus_slider_set(), RGB, rgb2hsl(), and update_saturation_slider_color().
Referenced by apply_autocolor(), apply_gain_neutralize(), apply_gamma_neutralize(), apply_lift_neutralize(), and gui_changed().
|
inlinestatic |
Definition at line 679 of file colorbalance.c.
References B, CHANNEL_BLUE, CHANNEL_GREEN, CHANNEL_RED, dt_bauhaus_slider_set(), dt_gui_freeze_begin, dt_gui_freeze_end, hsl2rgb(), p, R, and rgb.
| void set_visible_widgets | ( | dt_iop_colorbalance_gui_data_t * | g | ) |
Definition at line 1287 of file colorbalance.c.
References BOTH, dt_bauhaus_combobox_get(), dt_conf_set_string(), g, HSL, LEGACY, RGBL, and SLOPE_OFFSET_POWER.
Referenced by controls_callback(), gui_changed(), and gui_reset().
Definition at line 666 of file colorbalance.c.
References dt_bauhaus_slider_set_stop(), hsl2rgb(), and rgb.
Referenced by set_HSL_sliders().