Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
main.c File Reference
#include "chart/dtcairo.h"
#include "chart/colorchart.h"
#include "chart/common.h"
#include "chart/deltaE.h"
#include "chart/pfm.h"
#include "chart/thinplate.h"
#include "chart/tonecurve.h"
#include "common/exif.h"
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for chart/main.c:

Data Structures

struct  dt_lut_t
 

Macros

#define MAX_PATCHES   49
 
#define SWAP(a, b)
 

Typedefs

typedef struct dt_lut_t dt_lut_t
 

Enumerations

enum  {
  COLUMN_NAME ,
  COLUMN_RGB_IN ,
  COLUMN_LAB_IN ,
  COLUMN_LAB_REF ,
  COLUMN_DE_1976 ,
  COLUMN_DE_1976_FLOAT ,
  COLUMN_DE_2000 ,
  COLUMN_DE_2000_FLOAT ,
  NUM_COLUMNS
}
 

Functions

static void init_image (dt_lut_t *self, image_t *image, GCallback motion_cb)
 
static void image_lab_to_xyz (float *image, const int width, const int height)
 
static void map_boundingbox_to_view (image_t *image, point_t *bb)
 
static point_t map_point_to_view (image_t *image, point_t p)
 
static void get_xyz_sample_from_image (const image_t *const image, float shrink, box_t *box, float *xyz)
 
static void add_column (GtkTreeView *treeview, const char *title, int column_id, int sort_column)
 
static void update_table (dt_lut_t *self)
 
static void init_table (dt_lut_t *self)
 
static void get_Lab_from_box (box_t *box, float *Lab)
 
static void collect_source_patches (dt_lut_t *self)
 
static void collect_source_patches_foreach (gpointer key, gpointer value, gpointer user_data)
 
static void collect_reference_patches (dt_lut_t *self)
 
static void collect_reference_patches_foreach (gpointer key, gpointer value, gpointer user_data)
 
static box_tfind_patch (GHashTable *table, gpointer key)
 
static void get_boundingbox (const image_t *const image, point_t *bb)
 
static box_t get_sample_box (chart_t *chart, box_t *outer_box, float shrink)
 
static void get_corners (const float *homography, box_t *box, point_t *corners)
 
static void get_pixel_region (const image_t *const image, const point_t *const corners, int *x_start, int *y_start, int *x_end, int *y_end)
 
static void reset_bb (image_t *image)
 
static void free_image (image_t *image)
 
static gboolean handle_motion (GtkWidget *widget, GdkEventMotion *event, dt_lut_t *self, image_t *image)
 
static int find_closest_corner (point_t *bb, float x, float y)
 
static void map_mouse_to_0_1 (GtkWidget *widget, GdkEventMotion *event, image_t *image, float *x, float *y)
 
static void update_corner (image_t *image, int which, float *x, float *y)
 
static gboolean open_source_image (dt_lut_t *self, const char *filename)
 
static gboolean open_reference_image (dt_lut_t *self, const char *filename)
 
static gboolean open_image (image_t *image, const char *filename)
 
static gboolean open_cht (dt_lut_t *self, const char *filename)
 
static gboolean open_it8 (dt_lut_t *self, const char *filename)
 
static void size_allocate_callback (GtkWidget *widget, GdkRectangle *allocation, gpointer user_data)
 
static gboolean draw_image_callback (GtkWidget *widget, cairo_t *cr, gpointer user_data)
 
static gboolean motion_notify_callback_source (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
 
static gboolean motion_notify_callback_reference (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
 
static void source_image_changed_callback (GtkFileChooserButton *widget, gpointer user_data)
 
static void ref_image_changed_callback (GtkFileChooserButton *widget, gpointer user_data)
 
static char * get_filename_base (const char *filename)
 
static void cht_changed_callback (GtkFileChooserButton *widget, gpointer user_data)
 
static void reference_mode_changed_callback (GtkComboBox *widget, gpointer user_data)
 
static void it8_changed_callback (GtkFileChooserButton *widget, gpointer user_data)
 
static char * get_export_filename (dt_lut_t *self, const char *extension, char **name, char **description, gboolean *basecurve, gboolean *colorchecker, gboolean *colorin, gboolean *tonecurve)
 
static void print_patches (dt_lut_t *self, FILE *fd, GList *patch_names)
 
static void print_xml_plugin (FILE *fd, int num, int op_version, const char *operation, const char *op_params, gboolean enabled)
 
static void export_style (dt_lut_t *self, const char *filename, const char *name, const char *description, gboolean include_basecurve, gboolean include_colorchecker, gboolean include_colorin, gboolean include_tonecurve)
 
static void export_raw (dt_lut_t *self, char *filename, char *name, char *description)
 
static void export_raw_button_clicked_callback (GtkButton *button, gpointer user_data)
 
static void export_button_clicked_callback (GtkButton *button, gpointer user_data)
 
static void add_patches_to_array (dt_lut_t *self, GList *patch_names, int *N, int *i, double *target_L, double *target_a, double *target_b, double *colorchecker_Lab)
 
static void add_hdr_patches (int *N, double **target_L, double **target_a, double **target_b, double **colorchecker_Lab)
 
static char * encode_tonecurve (const tonecurve_t *c)
 
static char * encode_colorchecker (int num, const double *point, const double **target, int *permutation)
 
static int compare_L_source (const void *x_, const void *y_)
 
static void process_data (dt_lut_t *self, double *target_L, double *target_a, double *target_b, double *colorchecker_Lab, int N, int sparsity)
 
static void process_button_clicked_callback (GtkButton *button, gpointer user_data)
 
static void cht_state_callback (GtkWidget *widget, GtkStateFlags flags, gpointer user_data)
 
static void shrink_changed_callback (GtkRange *range, gpointer user_data)
 
static GtkWidget * create_notebook_page_source (dt_lut_t *self)
 
static GtkWidget * create_notebook_page_reference (dt_lut_t *self)
 
static GtkWidget * create_notebook_page_process (dt_lut_t *self)
 
static GtkWidget * create_notebook (dt_lut_t *self)
 
static GtkWidget * create_table (dt_lut_t *self)
 
static int main_gui (dt_lut_t *self, int argc, char *argv[])
 
static int parse_csv (dt_lut_t *self, const char *filename, double **target_L_ptr, double **target_a_ptr, double **target_b_ptr, double **source_Lab_ptr, int *num_gray, char **name, char **description)
 
static int main_csv (dt_lut_t *self, int argc, char *argv[])
 
static void show_usage (const char *exe)
 
int main (int argc, char *argv[])
 

Variables

const double thrs = 200.0
 
static const point_t bb_ref [] = {{.x=.0, .y=.0}, {.x=1., .y=0.}, {.x=1., .y=1.}, {.x=0., .y=1.}}
 

Macro Definition Documentation

◆ MAX_PATCHES

#define MAX_PATCHES   49

◆ SWAP

#define SWAP (   a,
 
)
Value:
{ \
const float tmp = (a); \
(a) = (b); \
(b) = tmp; \
}

Typedef Documentation

◆ dt_lut_t

typedef struct dt_lut_t dt_lut_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
COLUMN_NAME 
COLUMN_RGB_IN 
COLUMN_LAB_IN 
COLUMN_LAB_REF 
COLUMN_DE_1976 
COLUMN_DE_1976_FLOAT 
COLUMN_DE_2000 
COLUMN_DE_2000_FLOAT 
NUM_COLUMNS 

Function Documentation

◆ add_column()

static void add_column ( GtkTreeView *  treeview,
const char *  title,
int  column_id,
int  sort_column 
)
static

Referenced by create_table().

◆ add_hdr_patches()

static void add_hdr_patches ( int *  N,
double **  target_L,
double **  target_a,
double **  target_b,
double **  colorchecker_Lab 
)
static

References colorchecker_Lab, FALSE, N, and TRUE.

Referenced by main_csv(), and process_button_clicked_callback().

◆ add_patches_to_array()

static void add_patches_to_array ( dt_lut_t self,
GList *  patch_names,
int *  N,
int *  i,
double target_L,
double target_a,
double target_b,
double colorchecker_Lab 
)
static

◆ cht_changed_callback()

static void cht_changed_callback ( GtkFileChooserButton *  widget,
gpointer  user_data 
)
static

References open_cht().

Referenced by create_notebook_page_source().

◆ cht_state_callback()

static void cht_state_callback ( GtkWidget *  widget,
GtkStateFlags  flags,
gpointer  user_data 
)
static

◆ collect_reference_patches()

static void collect_reference_patches ( dt_lut_t self)
static

◆ collect_reference_patches_foreach()

static void collect_reference_patches_foreach ( gpointer  key,
gpointer  value,
gpointer  user_data 
)
static

◆ collect_source_patches()

static void collect_source_patches ( dt_lut_t self)
static

◆ collect_source_patches_foreach()

static void collect_source_patches_foreach ( gpointer  key,
gpointer  value,
gpointer  user_data 
)
static

◆ compare_L_source()

static int compare_L_source ( const void x_,
const void y_ 
)
static

Referenced by process_data().

◆ create_notebook()

static GtkWidget * create_notebook ( dt_lut_t self)
static

◆ create_notebook_page_process()

static GtkWidget * create_notebook_page_process ( dt_lut_t self)
static

◆ create_notebook_page_reference()

◆ create_notebook_page_source()

◆ create_table()

◆ draw_image_callback()

◆ encode_colorchecker()

◆ encode_tonecurve()

◆ export_button_clicked_callback()

static void export_button_clicked_callback ( GtkButton *  button,
gpointer  user_data 
)
static

◆ export_raw()

static void export_raw ( dt_lut_t self,
char *  filename,
char *  name,
char *  description 
)
static

◆ export_raw_button_clicked_callback()

static void export_raw_button_clicked_callback ( GtkButton *  button,
gpointer  user_data 
)
static

◆ export_style()

static void export_style ( dt_lut_t self,
const char *  filename,
const char *  name,
const char *  description,
gboolean  include_basecurve,
gboolean  include_colorchecker,
gboolean  include_colorin,
gboolean  include_tonecurve 
)
static

◆ find_closest_corner()

static int find_closest_corner ( point_t bb,
float  x,
float  y 
)
static
Todo:
: only react when the distance < some threshold?

References point_t::x, and point_t::y.

Referenced by handle_motion().

◆ find_patch()

static box_t * find_patch ( GHashTable *  table,
gpointer  key 
)
static

References key.

Referenced by collect_source_patches_foreach().

◆ free_image()

static void free_image ( image_t image)
static

◆ get_boundingbox()

static void get_boundingbox ( const image_t *const  image,
point_t bb 
)
static

◆ get_corners()

static void get_corners ( const float *  homography,
box_t box,
point_t corners 
)
static

◆ get_export_filename()

static char * get_export_filename ( dt_lut_t self,
const char *  extension,
char **  name,
char **  description,
gboolean *  basecurve,
gboolean *  colorchecker,
gboolean *  colorin,
gboolean *  tonecurve 
)
static

◆ get_filename_base()

static char * get_filename_base ( const char *  filename)
static

Referenced by open_it8(), and open_reference_image().

◆ get_Lab_from_box()

static void get_Lab_from_box ( box_t box,
float *  Lab 
)
static

◆ get_pixel_region()

static void get_pixel_region ( const image_t *const  image,
const point_t *const  corners,
int *  x_start,
int *  y_start,
int *  x_end,
int *  y_end 
)
static

◆ get_sample_box()

static box_t get_sample_box ( chart_t chart,
box_t outer_box,
float  shrink 
)
static

◆ get_xyz_sample_from_image()

◆ handle_motion()

static gboolean handle_motion ( GtkWidget *  widget,
GdkEventMotion *  event,
dt_lut_t self,
image_t image 
)
static

◆ image_lab_to_xyz()

static void image_lab_to_xyz ( float *  image,
const int  width,
const int  height 
)
static

References dt_Lab_to_XYZ(), height, and width.

Referenced by open_image().

◆ init_image()

static void init_image ( dt_lut_t self,
image_t image,
GCallback  motion_cb 
)
static

◆ init_table()

static void init_table ( dt_lut_t self)
static

◆ it8_changed_callback()

static void it8_changed_callback ( GtkFileChooserButton *  widget,
gpointer  user_data 
)
static

References open_it8().

Referenced by create_notebook_page_reference().

◆ main()

◆ main_csv()

static int main_csv ( dt_lut_t self,
int  argc,
char *  argv[] 
)
static
Todo:
: add command line options to control what modules to include

References add_hdr_patches(), colorchecker_Lab, description(), export_style(), N, name, parse_csv(), process_data(), and TRUE.

Referenced by main().

◆ main_gui()

◆ map_boundingbox_to_view()

static void map_boundingbox_to_view ( image_t image,
point_t bb 
)
static

References image_t::bb, and map_point_to_view().

Referenced by draw_image_callback().

◆ map_mouse_to_0_1()

static void map_mouse_to_0_1 ( GtkWidget *  widget,
GdkEventMotion *  event,
image_t image,
float *  x,
float *  y 
)
static

References height, image_t::offset_x, image_t::offset_y, and width.

Referenced by handle_motion().

◆ map_point_to_view()

static point_t map_point_to_view ( image_t image,
point_t  p 
)
static

◆ motion_notify_callback_reference()

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

◆ motion_notify_callback_source()

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

◆ open_cht()

◆ open_image()

◆ open_it8()

◆ open_reference_image()

◆ open_source_image()

static gboolean open_source_image ( dt_lut_t self,
const char *  filename 
)
static

◆ parse_csv()

static int parse_csv ( dt_lut_t self,
const char *  filename,
double **  target_L_ptr,
double **  target_a_ptr,
double **  target_b_ptr,
double **  source_Lab_ptr,
int *  num_gray,
char **  name,
char **  description 
)
static

References description(), f(), key, N, name, and thrs.

Referenced by main_csv().

◆ print_patches()

static void print_patches ( dt_lut_t self,
FILE *  fd,
GList *  patch_names 
)
static

◆ print_xml_plugin()

static void print_xml_plugin ( FILE *  fd,
int  num,
int  op_version,
const char *  operation,
const char *  op_params,
gboolean  enabled 
)
static

Referenced by export_style().

◆ process_button_clicked_callback()

◆ process_data()

◆ ref_image_changed_callback()

static void ref_image_changed_callback ( GtkFileChooserButton *  widget,
gpointer  user_data 
)
static

◆ reference_mode_changed_callback()

static void reference_mode_changed_callback ( GtkComboBox *  widget,
gpointer  user_data 
)
static

◆ reset_bb()

static void reset_bb ( image_t image)
static

◆ show_usage()

static void show_usage ( const char *  exe)
static

Referenced by main().

◆ shrink_changed_callback()

static void shrink_changed_callback ( GtkRange *  range,
gpointer  user_data 
)
static

◆ size_allocate_callback()

static void size_allocate_callback ( GtkWidget *  widget,
GdkRectangle *  allocation,
gpointer  user_data 
)
static

References set_offset_and_scale(), and image_t::width.

Referenced by init_image().

◆ source_image_changed_callback()

static void source_image_changed_callback ( GtkFileChooserButton *  widget,
gpointer  user_data 
)
static

◆ update_corner()

static void update_corner ( image_t image,
int  which,
float *  x,
float *  y 
)
static

◆ update_table()

Variable Documentation

◆ bb_ref

const point_t bb_ref[] = {{.x=.0, .y=.0}, {.x=1., .y=0.}, {.x=1., .y=1.}, {.x=0., .y=1.}}
static

◆ thrs