![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "bauhaus/bauhaus.h"#include "common/exif.h"#include "common/colorspaces_inline_conversions.h"#include "common/opencl.h"#include "develop/blend.h"#include "develop/imageop.h"#include "develop/imageop_math.h"#include "develop/imageop_gui.h"#include "dtgtk/gradientslider.h"#include "gui/gtk.h"#include "gui/presets.h"#include "gui/color_picker_proxy.h"#include "iop/iop_api.h"#include <stdlib.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 1552 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 95 of file colorbalance.c.
| Enumerator | |
|---|---|
| LIFT | |
| GAMMA | |
| GAIN | |
| LEVELS | |
Definition at line 104 of file colorbalance.c.
| Enumerator | |
|---|---|
| INVALID | |
| USER_SELECTED | |
| AUTO_SELECTED | |
Definition at line 119 of file colorbalance.c.
| enum _controls_t |
| Enumerator | |
|---|---|
| HSL | |
| RGBL | |
| BOTH | |
Definition at line 112 of file colorbalance.c.
| Enumerator | |
|---|---|
| LIFT_GAMMA_GAIN | |
| SLOPE_OFFSET_POWER | |
| LEGACY | |
Definition at line 88 of file colorbalance.c.
|
inlinestatic |
Definition at line 724 of file colorbalance.c.
References dt_bauhaus_widget_set_label(), g, GAIN, GAMMA, dt_iop_module_t::gui_data, LIFT, and USER_SELECTED.
Referenced by color_picker_apply(), gui_reset(), and gui_update().
|
static |
Definition at line 1502 of file colorbalance.c.
References dt_conf_get_string(), dt_free, DT_GUI_BOX_SPACING, dt_ui_section_label_new(), g, dt_iop_module_t::gui_data, and i.
Referenced by _cycle_layout_callback(), gui_changed(), gui_cleanup(), and gui_init().
|
static |
Definition at line 1547 of file colorbalance.c.
References _configure_slider_blocks().
Referenced by gui_init().
|
static |
Definition at line 276 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 181 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 971 of file colorbalance.c.
References AUTO_SELECTED, CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_iop_color_picker_reset(), dt_Lab_to_XYZ(), dt_prophotorgb_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAIN, GAMMA, darktable_t::gui, dt_iop_module_t::gui_data, INVALID, LIFT, MAX, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, dt_gui_gtk_t::reset, RGB, set_HSL_sliders(), TRUE, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 742 of file colorbalance.c.
References CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_Lab_to_XYZ(), dt_prophotorgb_to_XYZ(), dt_XYZ_to_prophotorgb(), g, darktable_t::gui, dt_iop_module_t::gui_data, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, dt_gui_gtk_t::reset, 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 1089 of file colorbalance.c.
References AUTO_SELECTED, CHANNEL_FACTOR, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_iop_color_picker_reset(), dt_Lab_to_XYZ(), g, GAIN, GAMMA, darktable_t::gui, dt_iop_module_t::gui_data, 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, dt_gui_gtk_t::reset, TRUE, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 947 of file colorbalance.c.
References CHANNEL_FACTOR, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAIN, darktable_t::gui, dt_iop_module_t::gui_data, p, dt_iop_module_t::params, dt_iop_module_t::picked_color_max, dt_gui_gtk_t::reset, RGB, TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 859 of file colorbalance.c.
References CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAIN, darktable_t::gui, dt_iop_module_t::gui_data, MAX, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, dt_gui_gtk_t::reset, RGB, set_HSL_sliders(), TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 922 of file colorbalance.c.
References CHANNEL_FACTOR, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAMMA, darktable_t::gui, dt_iop_module_t::gui_data, MAX, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, dt_gui_gtk_t::reset, RGB, TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 820 of file colorbalance.c.
References CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, GAMMA, darktable_t::gui, dt_iop_module_t::gui_data, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, dt_gui_gtk_t::reset, RGB, set_HSL_sliders(), TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 898 of file colorbalance.c.
References CHANNEL_FACTOR, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, darktable_t::gui, dt_iop_module_t::gui_data, LIFT, p, dt_iop_module_t::params, dt_iop_module_t::picked_color_min, dt_gui_gtk_t::reset, RGB, TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
static |
Definition at line 781 of file colorbalance.c.
References CDL(), CHANNEL_BLUE, CHANNEL_FACTOR, CHANNEL_GREEN, CHANNEL_RED, darktable, darktable_t::develop, dt_bauhaus_slider_set(), dt_dev_add_history_item, dt_Lab_to_XYZ(), dt_XYZ_to_prophotorgb(), g, darktable_t::gui, dt_iop_module_t::gui_data, LIFT, p, dt_iop_module_t::params, dt_iop_module_t::picked_color, dt_gui_gtk_t::reset, RGB, set_HSL_sliders(), TRUE, USER_SELECTED, and XYZ.
Referenced by color_picker_apply().
|
inlinestatic |
Definition at line 335 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 1280 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 1141 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(), g, and dt_iop_module_t::gui_data.
| 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 1188 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 1370 of file colorbalance.c.
References darktable, dt_iop_color_picker_reset(), g, darktable_t::gui, dt_iop_module_t::gui_data, dt_gui_gtk_t::reset, 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 205 of file colorbalance.c.
References IOP_CS_LAB.
| int default_group | ( | ) |
Definition at line 200 of file colorbalance.c.
References IOP_GROUP_COLOR.
| const char ** description | ( | struct dt_iop_module_t * | self | ) |
Definition at line 186 of file colorbalance.c.
References dt_iop_set_description().
| int flags | ( | ) |
Definition at line 195 of file colorbalance.c.
References IOP_FLAGS_DEPRECATED, IOP_FLAGS_INCLUDE_IN_STYLES, and IOP_FLAGS_SUPPORTS_BLENDING.
Definition at line 1575 of file colorbalance.c.
Definition at line 1574 of file colorbalance.c.
| void gui_changed | ( | dt_iop_module_t * | self, |
| GtkWidget * | w, | ||
| void * | previous | ||
| ) |
Definition at line 1347 of file colorbalance.c.
References _configure_slider_blocks(), darktable, g, darktable_t::gui, dt_iop_module_t::gui_data, IS_NULL_PTR, p, dt_iop_module_t::params, dt_gui_gtk_t::reset, set_HSL_sliders(), and set_visible_widgets().
Referenced by gui_update().
| void gui_cleanup | ( | struct dt_iop_module_t * | self | ) |
Definition at line 1816 of file colorbalance.c.
References _configure_slider_blocks(), darktable, DT_DEBUG_CONTROL_SIGNAL_DISCONNECT, IOP_GUI_FREE, and darktable_t::signals.
| void gui_init | ( | dt_iop_module_t * | self | ) |
Definition at line 1577 of file colorbalance.c.
References _configure_slider_blocks(), _cycle_layout_callback(), ADD_BLOCK, darktable_t::bauhaus, BOTH, controls_callback(), darktable, dt_bauhaus_combobox_add(), dt_bauhaus_combobox_from_params(), dt_bauhaus_combobox_new(), dt_bauhaus_combobox_set(), 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_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, darktable_t::signals, and TRUE.
| void gui_reset | ( | dt_iop_module_t * | self | ) |
Definition at line 1327 of file colorbalance.c.
References _check_tuner_picker_labels(), dt_bauhaus_combobox_set(), dt_iop_color_picker_reset(), g, dt_iop_module_t::gui_data, HSL, INVALID, k, LEVELS, set_visible_widgets(), and TRUE.
| void gui_update | ( | dt_iop_module_t * | self | ) |
Definition at line 1319 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 1274 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 308 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 210 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 218 of file colorbalance.c.
References CHANNEL_SIZE, d, dt_iop_module_t::default_params, i, LEGACY, and n.
Definition at line 1573 of file colorbalance.c.
| const char * name | ( | ) |
Definition at line 176 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 345 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 537 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 698 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 678 of file colorbalance.c.
References B, CHANNEL_BLUE, CHANNEL_GREEN, CHANNEL_RED, darktable, dt_bauhaus_slider_set(), darktable_t::gui, hsl2rgb(), p, R, dt_gui_gtk_t::reset, and rgb.
| void set_visible_widgets | ( | dt_iop_colorbalance_gui_data_t * | g | ) |
Definition at line 1286 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 665 of file colorbalance.c.
References dt_bauhaus_slider_set_stop(), hsl2rgb(), and rgb.
Referenced by set_HSL_sliders().