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