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