Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
toneequal.c File Reference
#include "common/extra_optimizations.h"
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "bauhaus/bauhaus.h"
#include "common/darktable.h"
#include "common/fast_guided_filter.h"
#include "common/eigf.h"
#include "common/interpolation.h"
#include "common/luminance_mask.h"
#include "common/opencl.h"
#include "common/collection.h"
#include "control/conf.h"
#include "control/control.h"
#include "develop/blend.h"
#include "develop/develop.h"
#include "develop/imageop.h"
#include "develop/imageop_math.h"
#include "develop/imageop_gui.h"
#include "dtgtk/drawingarea.h"
#include "dtgtk/expander.h"
#include "gui/color_picker_proxy.h"
#include "gui/draw.h"
#include "gui/gtk.h"
#include "gui/presets.h"
#include "iop/iop_api.h"
#include "iop/choleski.h"
+ Include dependency graph for toneequal.c:

Data Structures

struct  dt_iop_toneequalizer_params_t
 
struct  dt_iop_toneequalizer_data_t
 
struct  dt_iop_toneequalizer_global_data_t
 
struct  dt_iop_toneequalizer_gui_data_t
 

Macros

#define UI_SAMPLES   256
 
#define CONTRAST_FULCRUM   exp2f(-4.0f)
 
#define MIN_FLOAT   exp2f(-16.0f)
 
#define CHANNELS   9
 
#define PIXEL_CHAN   8
 
#define LUT_RESOLUTION   10000
 
#define DT_TONEEQ_USE_LUT   TRUE
 
#define TEMP_SAMPLES   2 * UI_SAMPLES
 

Typedefs

typedef enum dt_iop_toneequalizer_filter_t dt_iop_toneequalizer_filter_t
 
typedef struct dt_iop_toneequalizer_params_t dt_iop_toneequalizer_params_t
 
typedef struct dt_iop_toneequalizer_data_t dt_iop_toneequalizer_data_t
 
typedef struct dt_iop_toneequalizer_global_data_t dt_iop_toneequalizer_global_data_t
 
typedef struct dt_iop_toneequalizer_gui_data_t dt_iop_toneequalizer_gui_data_t
 

Enumerations

enum  dt_iop_toneequalizer_filter_t {
  DT_TONEEQ_NONE = 0 ,
  DT_TONEEQ_AVG_GUIDED ,
  DT_TONEEQ_GUIDED ,
  DT_TONEEQ_AVG_EIGF ,
  DT_TONEEQ_EIGF
}
 

Functions

const char * name ()
 
const char * aliases ()
 
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)
 
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 compress_shadows_highlight_preset_set_exposure_params (dt_iop_toneequalizer_params_t *p, const float step)
 
static void dilate_shadows_highlight_preset_set_exposure_params (dt_iop_toneequalizer_params_t *p, const float step)
 
void init_presets (dt_iop_module_so_t *self)
 
static gboolean in_mask_editing (dt_iop_module_t *self)
 
static void hash_set_get (uint64_t *hash_in, uint64_t *hash_out, dt_pthread_mutex_t *lock)
 
static void invalidate_luminance_cache (dt_iop_module_t *const self)
 
static int sanity_check (dt_iop_module_t *self)
 
static __DT_CLONE_TARGETS__ float get_luminance_from_buffer (const float *const buffer, const size_t width, const size_t height, const size_t x, const size_t y)
 
static __DT_CLONE_TARGETS__ float gaussian_denom (const float sigma)
 
static __DT_CLONE_TARGETS__ float gaussian_func (const float radius, const float denominator)
 
static __DT_CLONE_TARGETS__ void apply_toneequalizer (const float *const restrict in, const float *const restrict luminance, float *const restrict out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, const size_t ch, const dt_iop_toneequalizer_data_t *const d)
 
static __DT_CLONE_TARGETS__ float pixel_correction (const float exposure, const float *const restrict factors, const float sigma)
 
static __DT_CLONE_TARGETS__ void compute_luminance_mask (const float *const restrict in, float *const restrict luminance, const size_t width, const size_t height, const size_t ch, const dt_iop_toneequalizer_data_t *const d)
 
static __DT_CLONE_TARGETS__ void display_luminance_mask (const float *const restrict in, const float *const restrict luminance, float *const restrict out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out, dt_dev_pixelpipe_iop_t *piece, const size_t ch)
 
static __DT_CLONE_TARGETS__ void toneeq_process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const void *const restrict ivoid, void *const restrict ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
void modify_roi_in (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *roi_out, dt_iop_roi_t *roi_in)
 
static void compute_correction_lut (float *restrict lut, const float sigma, const float *const restrict factors)
 
static void get_channels_gains (float factors[9], const dt_iop_toneequalizer_params_t *p)
 
static void get_channels_factors (float factors[9], const dt_iop_toneequalizer_params_t *p)
 
static __DT_CLONE_TARGETS__ int compute_channels_factors (const float factors[8], float out[9], const float sigma)
 
static __DT_CLONE_TARGETS__ int compute_channels_gains (const float in[9], float out[9])
 
static int commit_channels_gains (const float factors[9], dt_iop_toneequalizer_params_t *p)
 
static void gui_cache_init (struct dt_iop_module_t *self)
 
static void build_interpolation_matrix (float A[9 *8], const float sigma)
 
static __DT_CLONE_TARGETS__ void compute_log_histogram_and_stats (const float *const restrict luminance, int histogram[256], const size_t num_elem, int *max_histogram, float *first_decile, float *last_decile)
 
static void update_histogram (struct dt_iop_module_t *const self)
 
static __DT_CLONE_TARGETS__ void compute_lut_correction (struct dt_iop_toneequalizer_gui_data_t *g, const float offset, const float scaling)
 
static gboolean update_curve_lut (struct dt_iop_module_t *self)
 
void init_global (dt_iop_module_so_t *module)
 
void cleanup_global (dt_iop_module_so_t *module)
 
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)
 
void show_guiding_controls (struct dt_iop_module_t *self)
 
void update_exposure_sliders (dt_iop_toneequalizer_gui_data_t *g, dt_iop_toneequalizer_params_t *p)
 
void gui_update (struct dt_iop_module_t *self)
 
void gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 
static void smoothing_callback (GtkWidget *slider, gpointer user_data)
 
static void auto_adjust_exposure_boost (GtkWidget *quad, gpointer user_data)
 
static void auto_adjust_contrast_boost (GtkWidget *quad, gpointer user_data)
 
static void show_luminance_mask_callback (GtkWidget *togglebutton, GdkEventButton *event, dt_iop_module_t *self)
 
static void switch_cursors (struct dt_iop_module_t *self)
 
int mouse_moved (struct dt_iop_module_t *self, double x, double y, double pressure, int which)
 
int mouse_leave (struct dt_iop_module_t *self)
 
static int set_new_params_interactive (const float control_exposure, const float exposure_offset, const float blending_sigma, dt_iop_toneequalizer_gui_data_t *g, dt_iop_toneequalizer_params_t *p)
 
int scrolled (struct dt_iop_module_t *self, double x, double y, int up, uint32_t state)
 
static gboolean _init_drawing (dt_iop_module_t *const restrict self, GtkWidget *widget, dt_iop_toneequalizer_gui_data_t *const restrict g)
 
void cairo_draw_hatches (cairo_t *cr, double center[2], double span[2], int instances, double line_width, double shade)
 
static void get_shade_from_luminance (cairo_t *cr, const float luminance, const float alpha)
 
static void draw_exposure_cursor (cairo_t *cr, const double pointerx, const double pointery, const double radius, const float luminance, const float zoom_scale, const int instances, const float alpha)
 
static void match_color_to_background (cairo_t *cr, const float exposure, const float alpha)
 
void gui_post_expose (struct dt_iop_module_t *self, cairo_t *cr, int32_t width, int32_t height, int32_t pointerx, int32_t pointery)
 
void gui_focus (struct dt_iop_module_t *self, gboolean in)
 
static void init_nodes_x (dt_iop_toneequalizer_gui_data_t *g)
 
static void init_nodes_y (dt_iop_toneequalizer_gui_data_t *g)
 
static gboolean area_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 
static gboolean area_enter_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean area_leave_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 
static gboolean area_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean area_motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
 
static gboolean area_button_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static gboolean notebook_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 
static void _develop_ui_pipe_started_callback (gpointer instance, gpointer user_data)
 
static void _develop_preview_pipe_finished_callback (gpointer instance, gpointer user_data)
 
static void _develop_ui_pipe_finished_callback (gpointer instance, gpointer user_data)
 
void gui_reset (struct dt_iop_module_t *self)
 
void gui_init (struct dt_iop_module_t *self)
 
void gui_cleanup (struct dt_iop_module_t *self)
 

Variables

static const float centers_ops[8] DT_ALIGNED_ARRAY
 
static const dt_colormatrix_t gauss_kernel
 

Macro Definition Documentation

◆ CHANNELS

#define CHANNELS   9

Build the exposures octaves : band-pass filters with gaussian windows spaced by 1 EV

◆ CONTRAST_FULCRUM

#define CONTRAST_FULCRUM   exp2f(-4.0f)

◆ DT_TONEEQ_USE_LUT

#define DT_TONEEQ_USE_LUT   TRUE

◆ LUT_RESOLUTION

#define LUT_RESOLUTION   10000

◆ MIN_FLOAT

#define MIN_FLOAT   exp2f(-16.0f)

◆ PIXEL_CHAN

#define PIXEL_CHAN   8

◆ TEMP_SAMPLES

#define TEMP_SAMPLES   2 * UI_SAMPLES

◆ UI_SAMPLES

#define UI_SAMPLES   256

Typedef Documentation

◆ dt_iop_toneequalizer_data_t

◆ dt_iop_toneequalizer_filter_t

◆ dt_iop_toneequalizer_global_data_t

◆ dt_iop_toneequalizer_gui_data_t

◆ dt_iop_toneequalizer_params_t

Enumeration Type Documentation

◆ dt_iop_toneequalizer_filter_t

Enumerator
DT_TONEEQ_NONE 
DT_TONEEQ_AVG_GUIDED 
DT_TONEEQ_GUIDED 
DT_TONEEQ_AVG_EIGF 
DT_TONEEQ_EIGF 

Function Documentation

◆ _develop_preview_pipe_finished_callback()

static void _develop_preview_pipe_finished_callback ( gpointer  instance,
gpointer  user_data 
)
static

◆ _develop_ui_pipe_finished_callback()

static void _develop_ui_pipe_finished_callback ( gpointer  instance,
gpointer  user_data 
)
static

◆ _develop_ui_pipe_started_callback()

static void _develop_ui_pipe_started_callback ( gpointer  instance,
gpointer  user_data 
)
static

◆ _init_drawing()

◆ aliases()

const char * aliases ( )

◆ apply_toneequalizer()

static __DT_CLONE_TARGETS__ void apply_toneequalizer ( const float *const restrict  in,
const float *const restrict  luminance,
float *const restrict  out,
const dt_iop_roi_t *const  roi_in,
const dt_iop_roi_t *const  roi_out,
const size_t  ch,
const dt_iop_toneequalizer_data_t *const  d 
)
inlinestatic

◆ area_button_press()

◆ area_button_release()

◆ area_draw()

◆ area_enter_notify()

static gboolean area_enter_notify ( GtkWidget *  widget,
GdkEventCrossing *  event,
gpointer  user_data 
)
static

◆ area_leave_notify()

◆ area_motion_notify()

static gboolean area_motion_notify ( GtkWidget *  widget,
GdkEventMotion *  event,
gpointer  user_data 
)
static

◆ auto_adjust_contrast_boost()

◆ auto_adjust_exposure_boost()

◆ build_interpolation_matrix()

static void build_interpolation_matrix ( float  A[9 *8],
const float  sigma 
)
inlinestatic

◆ cairo_draw_hatches()

void cairo_draw_hatches ( cairo_t *  cr,
double  center[2],
double  span[2],
int  instances,
double  line_width,
double  shade 
)

References double().

Referenced by draw_exposure_cursor().

◆ cleanup_global()

void cleanup_global ( dt_iop_module_so_t module)

◆ cleanup_pipe()

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

◆ commit_channels_gains()

static int commit_channels_gains ( const float  factors[9],
dt_iop_toneequalizer_params_t p 
)
static

◆ commit_params()

◆ compress_shadows_highlight_preset_set_exposure_params()

static void compress_shadows_highlight_preset_set_exposure_params ( dt_iop_toneequalizer_params_t p,
const float  step 
)
static

Referenced by init_presets().

◆ compute_channels_factors()

static __DT_CLONE_TARGETS__ int compute_channels_factors ( const float  factors[8],
float  out[9],
const float  sigma 
)
static

◆ compute_channels_gains()

static __DT_CLONE_TARGETS__ int compute_channels_gains ( const float  in[9],
float  out[9] 
)
static

References CHANNELS, and PIXEL_CHAN.

Referenced by set_new_params_interactive().

◆ compute_correction_lut()

static void compute_correction_lut ( float *restrict  lut,
const float  sigma,
const float *const restrict  factors 
)
static

◆ compute_log_histogram_and_stats()

static __DT_CLONE_TARGETS__ void compute_log_histogram_and_stats ( const float *const restrict  luminance,
int  histogram[256],
const size_t  num_elem,
int *  max_histogram,
float *  first_decile,
float *  last_decile 
)
inlinestatic

References TEMP_SAMPLES, and UI_SAMPLES.

Referenced by update_histogram().

◆ compute_luminance_mask()

◆ compute_lut_correction()

static __DT_CLONE_TARGETS__ void compute_lut_correction ( struct dt_iop_toneequalizer_gui_data_t g,
const float  offset,
const float  scaling 
)
inlinestatic

References pixel_correction(), and UI_SAMPLES.

Referenced by update_curve_lut().

◆ default_colorspace()

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

References IOP_CS_RGB.

◆ default_group()

int default_group ( )

References IOP_GROUP_TONES.

◆ description()

const char ** description ( struct dt_iop_module_t self)

◆ dilate_shadows_highlight_preset_set_exposure_params()

static void dilate_shadows_highlight_preset_set_exposure_params ( dt_iop_toneequalizer_params_t p,
const float  step 
)
static

Referenced by init_presets().

◆ display_luminance_mask()

static __DT_CLONE_TARGETS__ void display_luminance_mask ( const float *const restrict  in,
const float *const restrict  luminance,
float *const restrict  out,
const dt_iop_roi_t *const  roi_in,
const dt_iop_roi_t *const  roi_out,
dt_dev_pixelpipe_iop_t piece,
const size_t  ch 
)
inlinestatic

◆ draw_exposure_cursor()

static void draw_exposure_cursor ( cairo_t *  cr,
const double  pointerx,
const double  pointery,
const double  radius,
const float  luminance,
const float  zoom_scale,
const int  instances,
const float  alpha 
)
static

◆ flags()

◆ gaussian_denom()

◆ gaussian_func()

static __DT_CLONE_TARGETS__ float gaussian_func ( const float  radius,
const float  denominator 
)
static

◆ get_channels_factors()

static void get_channels_factors ( float  factors[9],
const dt_iop_toneequalizer_params_t p 
)
static

◆ get_channels_gains()

static void get_channels_gains ( float  factors[9],
const dt_iop_toneequalizer_params_t p 
)
static

References CHANNELS.

Referenced by get_channels_factors().

◆ get_luminance_from_buffer()

static __DT_CLONE_TARGETS__ float get_luminance_from_buffer ( const float *const  buffer,
const size_t  width,
const size_t  height,
const size_t  x,
const size_t  y 
)
static

◆ get_shade_from_luminance()

static void get_shade_from_luminance ( cairo_t *  cr,
const float  luminance,
const float  alpha 
)
static
Todo:
: fetch screen gamma from ICC display profile

Referenced by draw_exposure_cursor(), gui_post_expose(), and match_color_to_background().

◆ gui_cache_init()

static void gui_cache_init ( struct dt_iop_module_t self)
static

◆ gui_changed()

◆ gui_cleanup()

◆ gui_focus()

◆ gui_init()

◆ gui_post_expose()

◆ gui_reset()

◆ gui_update()

◆ hash_set_get()

static void hash_set_get ( uint64_t hash_in,
uint64_t hash_out,
dt_pthread_mutex_t *  lock 
)
static

◆ in_mask_editing()

static gboolean in_mask_editing ( dt_iop_module_t self)
static

◆ init_global()

void init_global ( dt_iop_module_so_t module)

◆ init_nodes_x()

static void init_nodes_x ( dt_iop_toneequalizer_gui_data_t g)
inlinestatic

References CHANNELS, and TRUE.

Referenced by area_draw().

◆ init_nodes_y()

static void init_nodes_y ( dt_iop_toneequalizer_gui_data_t g)
inlinestatic

References CHANNELS, and TRUE.

Referenced by area_draw().

◆ init_pipe()

◆ init_presets()

◆ invalidate_luminance_cache()

◆ legacy_params()

◆ match_color_to_background()

static void match_color_to_background ( cairo_t *  cr,
const float  exposure,
const float  alpha 
)
static
Todo:
: put that as a preference in anselrc

References get_shade_from_luminance().

Referenced by gui_post_expose().

◆ modify_roi_in()

◆ mouse_leave()

◆ mouse_moved()

◆ name()

const char * name ( )

◆ notebook_button_press()

static gboolean notebook_button_press ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

◆ pixel_correction()

static __DT_CLONE_TARGETS__ float pixel_correction ( const float  exposure,
const float *const restrict  factors,
const float  sigma 
)
inlinestatic

◆ process()

void process ( struct dt_iop_module_t self,
dt_dev_pixelpipe_iop_t piece,
const void *const restrict  ivoid,
void *const restrict  ovoid,
const dt_iop_roi_t *const  roi_in,
const dt_iop_roi_t *const  roi_out 
)

References toneeq_process().

◆ sanity_check()

◆ scrolled()

◆ set_new_params_interactive()

static int set_new_params_interactive ( const float  control_exposure,
const float  exposure_offset,
const float  blending_sigma,
dt_iop_toneequalizer_gui_data_t g,
dt_iop_toneequalizer_params_t p 
)
inlinestatic

◆ show_guiding_controls()

◆ show_luminance_mask_callback()

◆ smoothing_callback()

◆ switch_cursors()

◆ toneeq_process()

◆ update_curve_lut()

◆ update_exposure_sliders()

◆ update_histogram()

Variable Documentation

◆ DT_ALIGNED_ARRAY

const float centers_params [ 9 ] DT_ALIGNED_ARRAY
static
Initial value:
= {-56.0f / 7.0f,
-48.0f / 7.0f,
-40.0f / 7.0f,
-32.0f / 7.0f,
-24.0f / 7.0f,
-16.0f / 7.0f,
-8.0f / 7.0f,
0.0f / 7.0f}

Referenced by commit_params(), set_new_params_interactive(), smoothing_callback(), and update_curve_lut().

◆ gauss_kernel

const dt_colormatrix_t gauss_kernel
static
Initial value:
=
{ { 0.076555024f, 0.124401914f, 0.076555024f },
{ 0.124401914f, 0.196172249f, 0.124401914f },
{ 0.076555024f, 0.124401914f, 0.076555024f } }

Referenced by get_luminance_from_buffer().