Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
curve_tools.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2011-2020 darktable developers.
4
5 darktable is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 darktable is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with darktable. If not, see <http://www.gnu.org/licenses/>.
17
18 part of this file is based on nikon_curve.h from UFraw
19 Copyright 2004-2008 by Shawn Freeman, Udi Fuchs
20*/
21
22#pragma once
23
24// Curve Types
25#define CUBIC_SPLINE 0
26#define CATMULL_ROM 1
27#define MONOTONE_HERMITE 2
28
29// Maximum resolution allowed due to space considerations.
30#define MAX_RESOLUTION 65536
31#define MAX_ANCHORS 20
32
33// ERROR CODES
34#define CT_SUCCESS 0
35#define CT_ERROR 100
36#define CT_WARNING 104
37#define CT_SET_ERROR 200
38
39
42// DATA STRUCTURES
45/**********************************************************
46CurveData:
47 Structure for the curve data inside a NTC/NCV file.
48***********************************************************/
49typedef struct
50{
51 float x;
52 float y;
54
55typedef struct
56{
57 // Type for this curve
58 unsigned int m_spline_type;
59
60 // Box data
61 float m_min_x;
62 float m_max_x;
63 float m_min_y;
64 float m_max_y;
65
66 // Number of anchor points
67 unsigned char m_numAnchors;
68
69 // contains a list of anchors, 2 floats per each point, x-y format
70 // max is 20 points
72
73} CurveData;
74
75typedef struct
76{
77 // Number of samples to use for the curve.
78 unsigned int m_samplingRes;
79 unsigned int m_outputRes;
80
81 // Sampling array
82 unsigned short int *m_Samples; // jo: changed to short int to save memory
83
85
86/*********************************************
87CurveDataSample:
88 Samples from a spline curve constructed from
89 the curve data.
90
91 curve - Pointer to curve struct to hold the data.
92 sample - Pointer to sample struct to hold the data.
93**********************************************/
94int CurveDataSample(CurveData *curve, CurveSample *sample);
95
96/***************************************************************
97 * interpolate_set:
98 *
99 * convenience function for calculating the necessary parameters for
100 * interpolation.
101 *
102 * input:
103 * n - length of data arrays
104 * x - x axis of the data array
105 * y - y axis of the data array
106 * type - type of interpolation currently either CUBIC or HERMITE
107 * output:
108 * ypp - pointer to array of parameters
109 *******************************************************************/
110float *interpolate_set(int n, float x[], float y[], unsigned int type);
111
112/***************************************************************
113 * interpolate_val:
114 *
115 * convenience function for piecewise interpolation
116 *
117 * input:
118 * n - length of data arrays
119 * x - x axis of the data array
120 * xval - point where to interpolate
121 * y - y axis of the data array
122 * tangents - parameters calculated with interpolate_set
123 * type - type of interpolation currently either CUBIC or HERMITE
124 * output:
125 * yval - interpolated value at xval
126 *******************************************************************/
127float interpolate_val(int n, float x[], float xval, float y[], float tangents[], unsigned int type);
128
129// clang-format off
130// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
131// vim: shiftwidth=2 expandtab tabstop=2 cindent
132// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
133// clang-format on
134
int type
Definition common/metadata.c:42
float * interpolate_set(int n, float x[], float y[], unsigned int type)
Definition curve_tools.c:502
int CurveDataSample(CurveData *curve, CurveSample *sample)
Definition curve_tools.c:665
#define MAX_ANCHORS
Definition curve_tools.h:31
float interpolate_val(int n, float x[], float xval, float y[], float tangents[], unsigned int type)
Definition curve_tools.c:507
Definition curve_tools.h:50
float x
Definition curve_tools.h:51
float y
Definition curve_tools.h:52
Definition curve_tools.h:56
float m_min_x
Definition curve_tools.h:61
float m_max_x
Definition curve_tools.h:62
unsigned char m_numAnchors
Definition curve_tools.h:67
unsigned int m_spline_type
Definition curve_tools.h:58
float m_max_y
Definition curve_tools.h:64
float m_min_y
Definition curve_tools.h:63
Definition curve_tools.h:76
unsigned int m_outputRes
Definition curve_tools.h:79
unsigned int m_samplingRes
Definition curve_tools.h:78
unsigned short int * m_Samples
Definition curve_tools.h:82