Ansel 0.0
A darktable fork - bloat + design vision
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
dither.c File Reference
#include "bauhaus/bauhaus.h"
#include "common/imagebuf.h"
#include "common/imageio.h"
#include "common/math.h"
#include "common/opencl.h"
#include "common/tea.h"
#include "control/control.h"
#include "develop/develop.h"
#include "develop/imageop.h"
#include "develop/imageop_math.h"
#include "develop/imageop_gui.h"
#include "develop/tiling.h"
#include "dtgtk/gradientslider.h"
#include "gui/gtk.h"
#include "gui/presets.h"
#include "iop/iop_api.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <inttypes.h>
+ Include dependency graph for dither.c:

Data Structures

struct  dt_iop_dither_params_t
 
struct  dt_iop_dither_gui_data_t
 
struct  dt_iop_dither_data_t
 

Macros

#define clipnan_pixel_sse   clipnan_pixel
 
#define RIGHT_WT   (7.0f/16.0f)
 
#define DOWNRIGHT_WT   (1.0f/16.0f)
 
#define DOWN_WT   (5.0f/16.0f)
 
#define DOWNLEFT_WT   (3.0f/16.0f)
 
#define PROCESS_PIXEL_FULL(_pixel, inpix)
 
#define PROCESS_PIXEL_LEFT(_pixel, inpix)
 
#define PROCESS_PIXEL_RIGHT(pixel)
 

Typedefs

typedef enum dt_iop_dither_type_t dt_iop_dither_type_t
 
typedef struct dt_iop_dither_params_t dt_iop_dither_params_t
 
typedef struct dt_iop_dither_gui_data_t dt_iop_dither_gui_data_t
 
typedef struct dt_iop_dither_data_t dt_iop_dither_data_t
 

Enumerations

enum  dt_iop_dither_type_t {
  DITHER_RANDOM ,
  DITHER_FS1BIT ,
  DITHER_FS4BIT_GRAY ,
  DITHER_FS8BIT ,
  DITHER_FS16BIT ,
  DITHER_FSAUTO
}
 

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, dt_dev_pixelpipe_iop_t *piece)
 
void init_presets (dt_iop_module_so_t *self)
 
void reload_defaults (dt_iop_module_t *module)
 
static float _quantize (const float val, const float f, const float rf)
 
static float _rgb_to_gray (const float *const restrict val)
 
static void nearest_color (float *const restrict val, float *const restrict err, int graymode, const float f, const float rf)
 
static void _diffuse_error (float *const restrict val, const float *const restrict err, const float factor)
 
static float clipnan (const float x)
 
static void clipnan_pixel (float *const restrict out, const float *const restrict in)
 
static int get_dither_parameters (const dt_iop_dither_data_t *const data, const dt_dev_pixelpipe_iop_t *const piece, const float scale, unsigned int *const restrict levels)
 
static void process_floyd_steinberg (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)
 
static void process_random (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 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 gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 
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 gui_update (struct dt_iop_module_t *self)
 
void gui_init (struct dt_iop_module_t *self)
 

Macro Definition Documentation

◆ clipnan_pixel_sse

#define clipnan_pixel_sse   clipnan_pixel

◆ DOWN_WT

#define DOWN_WT   (5.0f/16.0f)

◆ DOWNLEFT_WT

#define DOWNLEFT_WT   (3.0f/16.0f)

◆ DOWNRIGHT_WT

#define DOWNRIGHT_WT   (1.0f/16.0f)

◆ PROCESS_PIXEL_FULL

#define PROCESS_PIXEL_FULL (   _pixel,
  inpix 
)
Value:
{ \
float *const pixel_ = (_pixel); \
nearest_color(pixel_, err, graymode, f, rf); /* quantize pixel */ \
clipnan_pixel(pixel_ + downright,(inpix) + downright); /* prepare downright for first access */ \
_diffuse_error(pixel_ + right, err, RIGHT_WT); /* diffuse quantization error to neighbors */ \
_diffuse_error(pixel_ + downleft, err, DOWNLEFT_WT); \
_diffuse_error(pixel_ + down, err, DOWN_WT); \
_diffuse_error(pixel_ + downright, err, DOWNRIGHT_WT); \
}
#define RIGHT_WT
Definition dither.c:351
#define DOWNRIGHT_WT
Definition dither.c:352
#define DOWNLEFT_WT
Definition dither.c:354
#define DOWN_WT
Definition dither.c:353
static float f(const float t, const float c, const float x)
Definition graduatednd.c:173

◆ PROCESS_PIXEL_LEFT

#define PROCESS_PIXEL_LEFT (   _pixel,
  inpix 
)
Value:
{ \
float *const pixel_ = (_pixel); \
nearest_color(pixel_, err, graymode, f, rf); /* quantize pixel */ \
clipnan_pixel(pixel_ + down,(inpix) + down); /* prepare down for first access */ \
clipnan_pixel(pixel_ + downright,(inpix) + downright); /* prepare downright for first access */ \
_diffuse_error(pixel_ + right, err, RIGHT_WT); /* diffuse quantization error to neighbors */ \
_diffuse_error(pixel_ + down, err, DOWN_WT); \
_diffuse_error(pixel_ + downright, err, DOWNRIGHT_WT); \
}

◆ PROCESS_PIXEL_RIGHT

#define PROCESS_PIXEL_RIGHT (   pixel)
Value:
nearest_color(pixel, err, graymode, f, rf); /* quantize pixel */ \
_diffuse_error(pixel + downleft, err, DOWNLEFT_WT); /* diffuse quantization error to neighbors */ \
_diffuse_error(pixel + down, err, DOWN_WT);
static void nearest_color(float *const restrict val, float *const restrict err, int graymode, const float f, const float rf)
Definition dither.c:171

◆ RIGHT_WT

#define RIGHT_WT   (7.0f/16.0f)

Typedef Documentation

◆ dt_iop_dither_data_t

◆ dt_iop_dither_gui_data_t

◆ dt_iop_dither_params_t

◆ dt_iop_dither_type_t

Enumeration Type Documentation

◆ dt_iop_dither_type_t

Enumerator
DITHER_RANDOM 
DITHER_FS1BIT 
DITHER_FS4BIT_GRAY 
DITHER_FS8BIT 
DITHER_FS16BIT 
DITHER_FSAUTO 

Function Documentation

◆ _diffuse_error()

static void _diffuse_error ( float *const restrict  val,
const float *const restrict  err,
const float  factor 
)
inlinestatic

References factor.

Referenced by process_floyd_steinberg().

◆ _quantize()

static float _quantize ( const float  val,
const float  f,
const float  rf 
)
inlinestatic

References f().

Referenced by nearest_color().

◆ _rgb_to_gray()

static float _rgb_to_gray ( const float *const restrict  val)
inlinestatic

Referenced by nearest_color().

◆ cleanup_pipe()

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

◆ clipnan()

static float clipnan ( const float  x)
inlinestatic

Referenced by clipnan_pixel().

◆ clipnan_pixel()

static void clipnan_pixel ( float *const restrict  out,
const float *const restrict  in 
)
inlinestatic

References clipnan().

Referenced by process_floyd_steinberg().

◆ 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_RGB.

◆ default_group()

int default_group ( )

References IOP_GROUP_TECHNICAL.

◆ description()

const char ** description ( struct dt_iop_module_t self)

◆ flags()

int flags ( )

◆ get_dither_parameters()

◆ gui_changed()

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

◆ gui_init()

◆ gui_update()

◆ init_pipe()

◆ init_presets()

◆ name()

const char * name ( )

◆ nearest_color()

static void nearest_color ( float *const restrict  val,
float *const restrict  err,
int  graymode,
const float  f,
const float  rf 
)
inlinestatic

References _quantize(), _rgb_to_gray(), and f().

Referenced by process_floyd_steinberg().

◆ process()

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 
)

◆ process_floyd_steinberg()

◆ process_random()

◆ reload_defaults()

void reload_defaults ( dt_iop_module_t module)