Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
main.c File Reference
#include <gtk/gtk.h>
#include "system/macros.h"
#include "system/mem_alloc.h"
#include "system/openmp.h"
#include "system/simd.h"
#include "apps/ansel-chart/dtcairo.h"
#include "apps/ansel-chart/colorchart.h"
#include "apps/ansel-chart/common.h"
#include "apps/ansel-chart/deltaE.h"
#include "apps/ansel-chart/pfm.h"
#include "math/attic/thinplate.h"
#include "apps/ansel-chart/tonecurve.h"
#include "metadata/exif.h"
#include <glib/gstdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "osx/osx.h"
#include "win/main_wrapper.h"
Include dependency graph for ansel-chart/main.c:

Go to the source code of this file.

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_t * find_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,
b )
Value:
{ \
const float tmp = (a); \
(a) = (b); \
(b) = tmp; \
}

Referenced by encode_colorchecker().

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 

Definition at line 63 of file ansel-chart/main.c.

Function Documentation

◆ add_column()

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

Definition at line 1370 of file ansel-chart/main.c.

Referenced by create_table().

◆ add_hdr_patches()

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

Definition at line 796 of file ansel-chart/main.c.

References colorchecker_Lab, FALSE, memcpy(), N, and TRUE.

Referenced by main_csv(), and process_button_clicked_callback().

◆ add_patches_to_array()

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()

void cht_changed_callback ( GtkFileChooserButton * widget,
gpointer user_data )
static

Definition at line 415 of file ansel-chart/main.c.

References dt_free, and open_cht().

Referenced by create_notebook_page_source().

◆ cht_state_callback()

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

◆ collect_reference_patches()

void collect_reference_patches ( dt_lut_t * self)
static

◆ collect_reference_patches_foreach()

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

◆ collect_source_patches()

void collect_source_patches ( dt_lut_t * self)
static

◆ collect_source_patches_foreach()

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

◆ compare_L_source()

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

Definition at line 970 of file ansel-chart/main.c.

References x.

Referenced by process_data().

◆ create_notebook()

GtkWidget * create_notebook ( dt_lut_t * self)
static

◆ create_notebook_page_process()

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()

void export_button_clicked_callback ( GtkButton * button,
gpointer user_data )
static

◆ export_raw()

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

◆ export_raw_button_clicked_callback()

void export_raw_button_clicked_callback ( GtkButton * button,
gpointer user_data )
static

◆ export_style()

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()

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

Definition at line 256 of file ansel-chart/main.c.

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

Referenced by handle_motion().

◆ find_patch()

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

Definition at line 1512 of file ansel-chart/main.c.

References dt_calloc_align(), IS_NULL_PTR, and key.

Referenced by collect_source_patches_foreach().

◆ free_image()

void free_image ( image_t * image)
static

Definition at line 1652 of file ansel-chart/main.c.

References dt_free, image_t::image, IS_NULL_PTR, reset_bb(), image_t::surface, and image_t::xyz.

Referenced by main(), and open_image().

◆ get_boundingbox()

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

Definition at line 1575 of file ansel-chart/main.c.

References image_t::bb, image_t::height, i, image_t::width, point_t::x, and point_t::y.

Referenced by get_xyz_sample_from_image().

◆ get_corners()

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

◆ get_export_filename()

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()

char * get_filename_base ( const char * filename)
static

Definition at line 335 of file ansel-chart/main.c.

Referenced by open_it8(), and open_reference_image().

◆ get_Lab_from_box()

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

◆ get_pixel_region()

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()

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

◆ get_xyz_sample_from_image()

◆ handle_motion()

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

◆ image_lab_to_xyz()

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

Definition at line 1664 of file ansel-chart/main.c.

References __OMP_PARALLEL_FOR__, dt_Lab_to_XYZ(), height, width, and x.

Referenced by open_image().

◆ init_image()

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

◆ init_table()

void init_table ( dt_lut_t * self)
static

◆ it8_changed_callback()

void it8_changed_callback ( GtkFileChooserButton * widget,
gpointer user_data )
static

Definition at line 485 of file ansel-chart/main.c.

References dt_free, and open_it8().

Referenced by create_notebook_page_reference().

◆ main()

◆ main_csv()

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

Definition at line 1853 of file ansel-chart/main.c.

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

Referenced by main().

◆ main_gui()

◆ map_boundingbox_to_view()

void map_boundingbox_to_view ( image_t * image,
point_t * bb )
static

Definition at line 175 of file ansel-chart/main.c.

References image_t::bb, i, and map_point_to_view().

Referenced by draw_image_callback().

◆ map_mouse_to_0_1()

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

Definition at line 275 of file ansel-chart/main.c.

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

Referenced by handle_motion().

◆ map_point_to_view()

point_t map_point_to_view ( image_t * image,
point_t p )
static

Definition at line 180 of file ansel-chart/main.c.

References image_t::height, p, image_t::scale, image_t::width, point_t::x, and point_t::y.

Referenced by map_boundingbox_to_view().

◆ motion_notify_callback_reference()

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

◆ motion_notify_callback_source()

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()

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

◆ parse_csv()

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

Definition at line 1745 of file ansel-chart/main.c.

References d, description(), f, i, IS_NULL_PTR, key, N, name, thrs, and value.

Referenced by main_csv().

◆ print_patches()

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

◆ print_xml_plugin()

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

Definition at line 641 of file ansel-chart/main.c.

References enabled.

Referenced by export_style().

◆ process_button_clicked_callback()

◆ process_data()

void process_data ( dt_lut_t * self,
double * target_L,
double * target_a,
double * target_b,
double * colorchecker_Lab,
int N,
int sparsity )
static

◆ ref_image_changed_callback()

void ref_image_changed_callback ( GtkFileChooserButton * widget,
gpointer user_data )
static

Definition at line 327 of file ansel-chart/main.c.

References dt_free, and open_reference_image().

Referenced by create_notebook_page_reference().

◆ reference_mode_changed_callback()

void reference_mode_changed_callback ( GtkComboBox * widget,
gpointer user_data )
static

◆ reset_bb()

void reset_bb ( image_t * image)
static

Definition at line 1627 of file ansel-chart/main.c.

References image_t::bb, BOTTOM_LEFT, BOTTOM_RIGHT, TOP_LEFT, TOP_RIGHT, point_t::x, and point_t::y.

Referenced by free_image(), and open_cht().

◆ show_usage()

void show_usage ( const char * exe)
static

Definition at line 1897 of file ansel-chart/main.c.

Referenced by main().

◆ shrink_changed_callback()

void shrink_changed_callback ( GtkRange * range,
gpointer user_data )
static

◆ size_allocate_callback()

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

Definition at line 128 of file ansel-chart/main.c.

References set_offset_and_scale(), and image_t::width.

Referenced by gui_init(), and init_image().

◆ source_image_changed_callback()

void source_image_changed_callback ( GtkFileChooserButton * widget,
gpointer user_data )
static

Definition at line 309 of file ansel-chart/main.c.

References dt_free, and open_source_image().

Referenced by create_notebook_page_source().

◆ update_corner()

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

Definition at line 284 of file ansel-chart/main.c.

References image_t::bb, BOTTOM_LEFT, BOTTOM_RIGHT, TOP_LEFT, TOP_RIGHT, point_t::x, x, and point_t::y.

Referenced by handle_motion().

◆ 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

Definition at line 61 of file ansel-chart/main.c.

Referenced by draw_image_callback(), and get_xyz_sample_from_image().

◆ thrs