Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
grain.c File Reference
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "bauhaus/bauhaus.h"
#include "common/math.h"
#include "control/control.h"
#include "develop/develop.h"
#include "develop/imageop.h"
#include "develop/imageop_gui.h"
#include "gui/gtk.h"
#include "iop/iop_api.h"
#include <gtk/gtk.h>
#include <inttypes.h>
+ Include dependency graph for grain.c:

Data Structures

struct  dt_iop_grain_params_t
 
struct  dt_iop_grain_gui_data_t
 
struct  dt_iop_grain_data_t
 

Macros

#define GRAIN_LIGHTNESS_STRENGTH_SCALE   0.15
 
#define GRAIN_HUE_COLORRANGE   0.392699082
 
#define GRAIN_HUE_STRENGTH_SCALE   0.25
 
#define GRAIN_SATURATION_STRENGTH_SCALE   0.25
 
#define GRAIN_RGB_STRENGTH_SCALE   0.25
 
#define GRAIN_SCALE_FACTOR   213.2
 
#define GRAIN_LUT_SIZE   128
 
#define GRAIN_LUT_DELTA_MAX   2.0
 
#define GRAIN_LUT_DELTA_MIN   0.0001
 
#define GRAIN_LUT_PAPER_GAMMA   1.0
 
#define FASTFLOOR(x)   (x > 0 ? (int)(x) : (int)(x)-1)
 
#define PRIME_LEVELS   4
 

Typedefs

typedef enum _dt_iop_grain_channel_t _dt_iop_grain_channel_t
 
typedef struct dt_iop_grain_params_t dt_iop_grain_params_t
 
typedef struct dt_iop_grain_gui_data_t dt_iop_grain_gui_data_t
 
typedef struct dt_iop_grain_data_t dt_iop_grain_data_t
 

Enumerations

enum  _dt_iop_grain_channel_t {
  DT_GRAIN_CHANNEL_HUE = 0 ,
  DT_GRAIN_CHANNEL_SATURATION ,
  DT_GRAIN_CHANNEL_LIGHTNESS ,
  DT_GRAIN_CHANNEL_RGB
}
 

Functions

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 _simplex_noise_init ()
 
static double dot (int g[], double x, double y, double z)
 
static double _simplex_noise (double xin, double yin, double zin)
 
static double _simplex_2d_noise (double x, double y, uint32_t octaves, double persistance, double z)
 
static float paper_resp (float exposure, float mb, float gp)
 
static float paper_resp_inverse (float density, float mb, float gp)
 
static void evaluate_grain_lut (float *grain_lut, const float mb)
 
static float dt_lut_lookup_2d_1c (const float *grain_lut, const float x, const float y)
 
const char * name ()
 
const char ** description (struct dt_iop_module_t *self)
 
int flags ()
 
int default_group ()
 
int default_colorspace (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
static unsigned int _hash_string (char *s)
 
void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
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 init_global (struct dt_iop_module_so_t *self)
 
void gui_init (struct dt_iop_module_t *self)
 

Variables

static int grad3 [12][3]
 
static int permutation []
 
static int perm [512]
 

Macro Definition Documentation

◆ FASTFLOOR

#define FASTFLOOR (   x)    (x > 0 ? (int)(x) : (int)(x)-1)

◆ GRAIN_HUE_COLORRANGE

#define GRAIN_HUE_COLORRANGE   0.392699082

◆ GRAIN_HUE_STRENGTH_SCALE

#define GRAIN_HUE_STRENGTH_SCALE   0.25

◆ GRAIN_LIGHTNESS_STRENGTH_SCALE

#define GRAIN_LIGHTNESS_STRENGTH_SCALE   0.15

◆ GRAIN_LUT_DELTA_MAX

#define GRAIN_LUT_DELTA_MAX   2.0

◆ GRAIN_LUT_DELTA_MIN

#define GRAIN_LUT_DELTA_MIN   0.0001

◆ GRAIN_LUT_PAPER_GAMMA

#define GRAIN_LUT_PAPER_GAMMA   1.0

◆ GRAIN_LUT_SIZE

#define GRAIN_LUT_SIZE   128

◆ GRAIN_RGB_STRENGTH_SCALE

#define GRAIN_RGB_STRENGTH_SCALE   0.25

◆ GRAIN_SATURATION_STRENGTH_SCALE

#define GRAIN_SATURATION_STRENGTH_SCALE   0.25

◆ GRAIN_SCALE_FACTOR

#define GRAIN_SCALE_FACTOR   213.2

◆ PRIME_LEVELS

#define PRIME_LEVELS   4

Typedef Documentation

◆ _dt_iop_grain_channel_t

◆ dt_iop_grain_data_t

◆ dt_iop_grain_gui_data_t

◆ dt_iop_grain_params_t

Enumeration Type Documentation

◆ _dt_iop_grain_channel_t

Enumerator
DT_GRAIN_CHANNEL_HUE 
DT_GRAIN_CHANNEL_SATURATION 
DT_GRAIN_CHANNEL_LIGHTNESS 
DT_GRAIN_CHANNEL_RGB 

Function Documentation

◆ _hash_string()

static unsigned int _hash_string ( char *  s)
static

Referenced by process().

◆ _simplex_2d_noise()

static double _simplex_2d_noise ( double  x,
double  y,
uint32_t  octaves,
double  persistance,
double  z 
)
static

References _simplex_noise(), and f().

Referenced by process().

◆ _simplex_noise()

static double _simplex_noise ( double  xin,
double  yin,
double  zin 
)
static

References dot(), FASTFLOOR, grad3, and perm.

Referenced by _simplex_2d_noise().

◆ _simplex_noise_init()

static void _simplex_noise_init ( )
static

References perm, and permutation.

Referenced by init_global().

◆ cleanup_pipe()

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

◆ commit_params()

◆ default_colorspace()

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

References IOP_CS_LAB.

◆ default_group()

int default_group ( )

References IOP_GROUP_EFFECTS.

◆ description()

const char ** description ( struct dt_iop_module_t self)

◆ dot()

◆ dt_lut_lookup_2d_1c()

static float dt_lut_lookup_2d_1c ( const float *  grain_lut,
const float  x,
const float  y 
)
static

References CLAMPS, and GRAIN_LUT_SIZE.

Referenced by process().

◆ evaluate_grain_lut()

static void evaluate_grain_lut ( float *  grain_lut,
const float  mb 
)
static

◆ flags()

◆ gui_init()

◆ init_global()

void init_global ( struct dt_iop_module_so_t self)

References _simplex_noise_init().

◆ init_pipe()

◆ legacy_params()

int legacy_params ( dt_iop_module_t self,
const void *const  old_params,
const int  old_version,
void new_params,
const int  new_version 
)

◆ name()

const char * name ( )

◆ paper_resp()

static float paper_resp ( float  exposure,
float  mb,
float  gp 
)
static

◆ paper_resp_inverse()

static float paper_resp_inverse ( float  density,
float  mb,
float  gp 
)
static

◆ process()

Variable Documentation

◆ grad3

int grad3[12][3]
static
Initial value:
= { { 1, 1, 0 },
{ -1, 1, 0 },
{ 1, -1, 0 },
{ -1, -1, 0 },
{ 1, 0, 1 },
{ -1, 0, 1 },
{ 1, 0, -1 },
{ -1, 0, -1 },
{ 0, 1, 1 },
{ 0, -1, 1 },
{ 0, 1, -1 },
{ 0, -1, -1 } }

Referenced by _simplex_noise().

◆ perm

int perm[512]
static

◆ permutation

int permutation[]
static
Initial value:
= { 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30,
69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62,
94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136,
171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122,
60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161,
1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86,
164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126,
255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213,
119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253,
19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193,
238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31,
181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93,
222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 }

Referenced by _simplex_noise_init(), encode_colorchecker(), and thinplate_match().