FFmpeg
|
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "internal.h"
#include "video.h"
#include <math.h>
Go to the source code of this file.
Data Structures | |
struct | ThreadData |
Used for passing data between threads. More... | |
struct | ColorConstancyContext |
Common struct for all algorithms contexts. More... | |
Macros | |
#define | GREY_EDGE "greyedge" |
#define | SQRT3 1.73205080757 |
#define | NUM_PLANES 3 |
#define | MAX_DIFF_ORD 2 |
#define | MAX_META_DATA 4 |
#define | MAX_DATA 4 |
#define | INDEX_TEMP 0 |
#define | INDEX_DX 1 |
#define | INDEX_DY 2 |
#define | INDEX_DXY 3 |
#define | INDEX_NORM INDEX_DX |
#define | INDEX_SRC 0 |
#define | INDEX_DST 1 |
#define | INDEX_ORD 2 |
#define | INDEX_DIR 3 |
#define | DIR_X 0 |
#define | DIR_Y 1 |
#define | OFFSET(x) offsetof(ColorConstancyContext, x) |
#define | FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
#define | GINDX(s, i) ( (i) - ((s) >> 2) ) |
#define | CLAMP(x, mx) av_clip((x), 0, (mx-1)) |
#define | INDX2D(r, c, w) ( (r) * (w) + (c) ) |
#define | GAUSS(s, sr, sc, sls, sh, sw, g) ( (s)[ INDX2D(CLAMP((sr), (sh)), CLAMP((sc), (sw)), (sls)) ] * (g) ) |
Functions | |
static int | set_gauss (AVFilterContext *ctx) |
Sets gauss filters used for calculating gauss derivatives. More... | |
static void | cleanup_derivative_buffers (ThreadData *td, int nb_buff, int nb_planes) |
Frees up buffers used by grey edge for storing derivatives final and intermidiate results. More... | |
static int | setup_derivative_buffers (AVFilterContext *ctx, ThreadData *td) |
Allocates buffers used by grey edge for storing derivatives final and intermidiate results. More... | |
static int | slice_get_derivative (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) |
Slice calculation of gaussian derivatives. More... | |
static int | slice_normalize (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) |
Slice Frobius normalization of gaussian derivatives. More... | |
static void av_always_inline | get_deriv (AVFilterContext *ctx, ThreadData *td, int ord, int dir, int src, int dst, int dim, int nb_threads) |
Utility function for setting up differentiation data/metadata. More... | |
static int | get_derivative (AVFilterContext *ctx, ThreadData *td) |
Main control function for calculating gaussian derivatives. More... | |
static int | filter_slice_grey_edge (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) |
Slice function for grey edge algorithm that does partial summing/maximizing of gaussian derivatives. More... | |
static int | filter_grey_edge (AVFilterContext *ctx, AVFrame *in) |
Main control function for grey edge algorithm. More... | |
static void | normalize_light (double *light) |
Normalizes estimated illumination since only illumination vector direction is required for color constancy. More... | |
static int | illumination_estimation (AVFilterContext *ctx, AVFrame *in) |
Redirects to corresponding algorithm estimation function and performs normalization after estimation. More... | |
static int | diagonal_transformation (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) |
Performs simple correction via diagonal transformation model. More... | |
static void | chromatic_adaptation (AVFilterContext *ctx, AVFrame *in, AVFrame *out) |
Main control function for correcting scene illumination based on estimated illumination. More... | |
static int | config_props (AVFilterLink *inlink) |
static int | filter_frame (AVFilterLink *inlink, AVFrame *in) |
static av_cold void | uninit (AVFilterContext *ctx) |
AVFILTER_DEFINE_CLASS (greyedge) | |
Variables | |
static const AVFilterPad | colorconstancy_inputs [] |
static const AVOption | greyedge_options [] |
const AVFilter | ff_vf_greyedge |
Color Constancy filter
[J]. van de Weijer, Th. Gevers, A. Gijsenij "Edge-Based Color Constancy".
Definition in file vf_colorconstancy.c.
#define GREY_EDGE "greyedge" |
Definition at line 40 of file vf_colorconstancy.c.
#define SQRT3 1.73205080757 |
Definition at line 42 of file vf_colorconstancy.c.
#define NUM_PLANES 3 |
Definition at line 44 of file vf_colorconstancy.c.
#define MAX_DIFF_ORD 2 |
Definition at line 45 of file vf_colorconstancy.c.
#define MAX_META_DATA 4 |
Definition at line 46 of file vf_colorconstancy.c.
#define MAX_DATA 4 |
Definition at line 47 of file vf_colorconstancy.c.
#define INDEX_TEMP 0 |
Definition at line 49 of file vf_colorconstancy.c.
#define INDEX_DX 1 |
Definition at line 50 of file vf_colorconstancy.c.
#define INDEX_DY 2 |
Definition at line 51 of file vf_colorconstancy.c.
#define INDEX_DXY 3 |
Definition at line 52 of file vf_colorconstancy.c.
#define INDEX_NORM INDEX_DX |
Definition at line 53 of file vf_colorconstancy.c.
#define INDEX_SRC 0 |
Definition at line 54 of file vf_colorconstancy.c.
#define INDEX_DST 1 |
Definition at line 55 of file vf_colorconstancy.c.
#define INDEX_ORD 2 |
Definition at line 56 of file vf_colorconstancy.c.
#define INDEX_DIR 3 |
Definition at line 57 of file vf_colorconstancy.c.
#define DIR_X 0 |
Definition at line 58 of file vf_colorconstancy.c.
#define DIR_Y 1 |
Definition at line 59 of file vf_colorconstancy.c.
#define OFFSET | ( | x | ) | offsetof(ColorConstancyContext, x) |
Definition at line 90 of file vf_colorconstancy.c.
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM |
Definition at line 91 of file vf_colorconstancy.c.
#define CLAMP | ( | x, | |
mx | |||
) | av_clip((x), 0, (mx-1)) |
Definition at line 231 of file vf_colorconstancy.c.
#define GAUSS | ( | s, | |
sr, | |||
sc, | |||
sls, | |||
sh, | |||
sw, | |||
g | |||
) | ( (s)[ INDX2D(CLAMP((sr), (sh)), CLAMP((sc), (sw)), (sls)) ] * (g) ) |
Definition at line 233 of file vf_colorconstancy.c.
|
static |
Sets gauss filters used for calculating gauss derivatives.
Filter size depends on sigma which is a user option hence we calculate these filters each time. Also each higher order depends on lower ones. Sigma can be zero only at difford = 0, then we only convert data to double instead.
ctx | the filter context. |
Definition at line 107 of file vf_colorconstancy.c.
Referenced by config_props().
|
static |
Frees up buffers used by grey edge for storing derivatives final and intermidiate results.
Number of buffers and number of planes for last buffer are given so it can be safely called at allocation failure instances.
td | holds the buffers. |
nb_buff | number of buffers to be freed. |
nb_planes | number of planes for last buffer to be freed. |
Definition at line 186 of file vf_colorconstancy.c.
Referenced by filter_grey_edge(), and setup_derivative_buffers().
|
static |
Allocates buffers used by grey edge for storing derivatives final and intermidiate results.
ctx | the filter context. |
td | holds the buffers. |
Definition at line 211 of file vf_colorconstancy.c.
Referenced by filter_grey_edge().
|
static |
Slice calculation of gaussian derivatives.
Applies 1-D gaussian derivative filter either horizontally or vertically according to meta data given in thread data. When convoluting horizontally source is always the in frame withing thread data while when convoluting vertically source is a buffer.
ctx | the filter context. |
arg | data to be passed between threads. |
jobnr | current job nubmer. |
nb_jobs | total number of jobs. |
Applying gauss horizontally along each row
Applying gauss vertically along each column
Definition at line 248 of file vf_colorconstancy.c.
Referenced by get_deriv().
|
static |
Slice Frobius normalization of gaussian derivatives.
Only called for difford values of 1 or 2.
ctx | the filter context. |
arg | data to be passed between threads. |
jobnr | current job nubmer. |
nb_jobs | total number of jobs. |
Definition at line 316 of file vf_colorconstancy.c.
Referenced by filter_grey_edge().
|
static |
Utility function for setting up differentiation data/metadata.
ctx | the filter context. |
td | to be used for passing data between threads. |
ord | ord of differentiation. |
dir | direction of differentiation. |
src | index of source used for differentiation. |
dst | index destination used for saving differentiation result. |
dim | maximum dimension in current direction. |
nb_threads | number of threads to use. |
Definition at line 362 of file vf_colorconstancy.c.
Referenced by get_derivative().
|
static |
Main control function for calculating gaussian derivatives.
ctx | the filter context. |
td | holds the buffers used for storing results. |
Definition at line 381 of file vf_colorconstancy.c.
Referenced by filter_grey_edge().
|
static |
Slice function for grey edge algorithm that does partial summing/maximizing of gaussian derivatives.
ctx | the filter context. |
arg | data to be passed between threads. |
jobnr | current job nubmer. |
nb_jobs | total number of jobs. |
Definition at line 437 of file vf_colorconstancy.c.
Referenced by filter_grey_edge().
|
static |
Main control function for grey edge algorithm.
ctx | the filter context. |
in | frame to perfrom grey edge on. |
Definition at line 486 of file vf_colorconstancy.c.
Referenced by illumination_estimation().
|
static |
Normalizes estimated illumination since only illumination vector direction is required for color constancy.
light | the estimated illumination to be normalized in place |
Definition at line 534 of file vf_colorconstancy.c.
Referenced by illumination_estimation().
|
static |
Redirects to corresponding algorithm estimation function and performs normalization after estimation.
ctx | the filter context. |
in | frame to perfrom estimation on. |
Definition at line 565 of file vf_colorconstancy.c.
Referenced by filter_frame().
|
static |
Performs simple correction via diagonal transformation model.
ctx | the filter context. |
arg | data to be passed between threads. |
jobnr | current job nubmer. |
nb_jobs | total number of jobs. |
Definition at line 591 of file vf_colorconstancy.c.
Referenced by chromatic_adaptation().
|
static |
Main control function for correcting scene illumination based on estimated illumination.
ctx | the filter context. |
in | holds frame to correct |
out | holds corrected frame |
Definition at line 626 of file vf_colorconstancy.c.
Referenced by filter_frame().
|
static |
Definition at line 637 of file vf_colorconstancy.c.
|
static |
Definition at line 665 of file vf_colorconstancy.c.
|
static |
Definition at line 698 of file vf_colorconstancy.c.
AVFILTER_DEFINE_CLASS | ( | greyedge | ) |
|
static |
Definition at line 709 of file vf_colorconstancy.c.
|
static |
Definition at line 718 of file vf_colorconstancy.c.
const AVFilter ff_vf_greyedge |
Definition at line 727 of file vf_colorconstancy.c.