Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
colormapping.c File Reference
#include "widgets/bauhaus.h"
#include "system/macros.h"
#include "system/openmp.h"
#include "system/target_clones.h"
#include "system/mem_alloc.h"
#include "system/simd.h"
#include "common/module_versioning.h"
#include <glib/gstdio.h>
#include "pixel/bilateral.h"
#include "colorprofiles/colorspaces.h"
#include "common/imagebuf.h"
#include "common/points.h"
#include "control/control.h"
#include "develop/develop.h"
#include "develop/imageop.h"
#include "develop/imageop_gui.h"
#include "develop/tiling.h"
#include "widgets/drawingarea.h"
#include "iop/iop_api.h"
#include <gtk/gtk.h>
#include <inttypes.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "widgets/label.h"
#include "gui/screen_metrics.h"
#include "control/signal.h"
+ Include dependency graph for colormapping.c:

Go to the source code of this file.

Data Structures

struct  dt_iop_colormapping_flowback_t
 
struct  dt_iop_colormapping_params_t
 
struct  dt_iop_colormapping_gui_data_t
 

Macros

#define HISTN   (1 << 11)
 
#define MAXN   5
 

Typedefs

typedef float float2[2]
 
typedef enum dt_iop_colormapping_flags_t dt_iop_colormapping_flags_t
 
typedef struct dt_iop_colormapping_flowback_t dt_iop_colormapping_flowback_t
 
typedef struct dt_iop_colormapping_params_t dt_iop_colormapping_params_t
 
typedef struct dt_iop_colormapping_params_t dt_iop_colormapping_data_t
 
typedef struct dt_iop_colormapping_gui_data_t dt_iop_colormapping_gui_data_t
 

Enumerations

enum  dt_iop_colormapping_flags_t {
  NEUTRAL = 0 ,
  HAS_SOURCE = 1 << 0 ,
  HAS_TARGET = 1 << 1 ,
  HAS_SOURCE_TARGET = HAS_SOURCE | HAS_TARGET ,
  ACQUIRE = 1 << 2 ,
  GET_SOURCE = 1 << 3 ,
  GET_TARGET = 1 << 4
}
 

Functions

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, const dt_dev_pixelpipe_iop_t *piece)
 
static void capture_histogram (const float *col, const int width, const int height, int *hist)
 
static void invert_histogram (const int *hist, float *inv_hist)
 
static __DT_CLONE_TARGETS__ void get_cluster_mapping (const int n, float2 *mi, const float *wi, float2 *mo, const float *wo, const float dominance, int *mapio)
 
static __DT_CLONE_TARGETS__ void get_clusters (const float *col, const int n, float2 *mean, float *weight)
 
static int get_cluster (const float *col, const int n, float2 *mean)
 
static void kmeans (const float *col, const int width, const int height, const int n, float2 *mean_out, float2 *var_out, float *weight_out)
 
__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)
 
void tiling_callback (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, struct dt_develop_tiling_t *tiling)
 
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 gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 
static void acquire_source_button_pressed (GtkButton *button, dt_iop_module_t *self)
 
static void acquire_target_button_pressed (GtkButton *button, dt_iop_module_t *self)
 
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 reload_defaults (dt_iop_module_t *module)
 
static gboolean cluster_preview_draw (GtkWidget *widget, cairo_t *crf, dt_iop_module_t *self)
 
static void process_clusters (gpointer instance, gpointer user_data)
 
void gui_init (struct dt_iop_module_t *self)
 
void gui_cleanup (struct dt_iop_module_t *self)
 

Macro Definition Documentation

◆ HISTN

#define HISTN   (1 << 11)

color transfer somewhat based on the glorious paper ‘color transfer between images’ by erik reinhard, michael ashikhmin, bruce gooch, and peter shirley, 2001. chosen because it officially cites the playboy.

workflow:

  • open the target image, press acquire button
  • right click store as preset
  • open image you want to transfer the color to
  • right click and apply the preset

Definition at line 87 of file colormapping.c.

◆ MAXN

#define MAXN   5

Definition at line 88 of file colormapping.c.

Typedef Documentation

◆ dt_iop_colormapping_data_t

and pixelpipe data is just the same

Definition at line 142 of file colormapping.c.

◆ dt_iop_colormapping_flags_t

◆ dt_iop_colormapping_flowback_t

◆ dt_iop_colormapping_gui_data_t

◆ dt_iop_colormapping_params_t

◆ float2

typedef float float2[2]

Definition at line 90 of file colormapping.c.

Enumeration Type Documentation

◆ dt_iop_colormapping_flags_t

Enumerator
NEUTRAL 
HAS_SOURCE 
HAS_TARGET 
HAS_SOURCE_TARGET 
ACQUIRE 
GET_SOURCE 
GET_TARGET 

Definition at line 92 of file colormapping.c.

Function Documentation

◆ acquire_source_button_pressed()

static void acquire_source_button_pressed ( GtkButton *  button,
dt_iop_module_t *  self 
)
static

◆ acquire_target_button_pressed()

static void acquire_target_button_pressed ( GtkButton *  button,
dt_iop_module_t *  self 
)
static

◆ capture_histogram()

static void capture_histogram ( const float *  col,
const int  width,
const int  height,
int *  hist 
)
static

Definition at line 193 of file colormapping.c.

References height, HISTN, i, k, L, and width.

Referenced by process_clusters().

◆ cleanup_pipe()

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

Definition at line 686 of file colormapping.c.

References dt_free_align, L, and piece.

◆ cluster_preview_draw()

static gboolean cluster_preview_draw ( GtkWidget *  widget,
cairo_t *  crf,
dt_iop_module_t *  self 
)
static

◆ commit_params()

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 627 of file colormapping.c.

References d, L, p, and piece.

◆ default_colorspace()

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

Definition at line 188 of file colormapping.c.

References IOP_CS_LAB.

◆ default_group()

int default_group ( )

Definition at line 178 of file colormapping.c.

References IOP_GROUP_COLOR.

◆ description()

const char ** description ( struct dt_iop_module_t *  self)

Definition at line 169 of file colormapping.c.

References dt_iop_set_description(), and L.

◆ flags()

int flags ( )

◆ get_cluster()

static int get_cluster ( const float *  col,
const int  n,
float2 *  mean 
)
static

Definition at line 298 of file colormapping.c.

References dist(), k, L, and n.

Referenced by kmeans().

◆ get_cluster_mapping()

static __DT_CLONE_TARGETS__ void get_cluster_mapping ( const int  n,
float2 *  mi,
const float *  wi,
float2 *  mo,
const float *  wo,
const float  dominance,
int *  mapio 
)
static

Definition at line 245 of file colormapping.c.

References dist(), L, and n.

Referenced by process().

◆ get_clusters()

static __DT_CLONE_TARGETS__ void get_clusters ( const float *  col,
const int  n,
float2 *  mean,
float *  weight 
)
static

Definition at line 278 of file colormapping.c.

References k, L, n, and weight().

Referenced by process().

◆ gui_changed()

void gui_changed ( dt_iop_module_t *  self,
GtkWidget *  w,
void *  previous 
)

◆ gui_cleanup()

◆ gui_init()

◆ init_pipe()

void init_pipe ( struct dt_iop_module_t *  self,
dt_dev_pixelpipe_t *  pipe,
dt_dev_pixelpipe_iop_t *  piece 
)

Definition at line 680 of file colormapping.c.

References dt_calloc_align(), and piece.

◆ invert_histogram()

static void invert_histogram ( const int *  hist,
float *  inv_hist 
)
static

Definition at line 212 of file colormapping.c.

References HISTN, i, k, and L.

Referenced by process_clusters().

◆ kmeans()

static void kmeans ( const float *  col,
const int  width,
const int  height,
const int  n,
float2 *  mean_out,
float2 *  var_out,
float *  weight_out 
)
static

Definition at line 315 of file colormapping.c.

References __OMP_PARALLEL_FOR__, dt_free, dt_points_get(), get_cluster(), height, i, k, L, Lab, n, and width.

Referenced by process_clusters().

◆ name()

const char * name ( )

Definition at line 164 of file colormapping.c.

References L.

◆ process()

◆ process_clusters()

◆ reload_defaults()

void reload_defaults ( dt_iop_module_t *  module)

Definition at line 692 of file colormapping.c.

References d, dt_iop_gui_data(), g, HAS_SOURCE, HISTN, IS_NULL_PTR, L, and MAXN.

◆ tiling_callback()