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#pragma once
31
32// Curve Types
33#define CUBIC_SPLINE 0
34#define CATMULL_ROM 1
35#define MONOTONE_HERMITE 2
36
37// Maximum resolution allowed due to space considerations.
38#define MAX_RESOLUTION 65536
39#define MAX_ANCHORS 20
40
41// ERROR CODES
42#define CT_SUCCESS 0
43#define CT_ERROR 100
44#define CT_WARNING 104
45#define CT_SET_ERROR 200
46
47
50// DATA STRUCTURES
53/**********************************************************
54CurveData:
55 Structure for the curve data inside a NTC/NCV file.
56***********************************************************/
57typedef struct
58{
59 float x;
60 float y;
62
63typedef struct
64{
65 // Type for this curve
66 unsigned int m_spline_type;
67
68 // Box data
69 float m_min_x;
70 float m_max_x;
71 float m_min_y;
72 float m_max_y;
73
74 // Number of anchor points
75 unsigned char m_numAnchors;
76
77 // contains a list of anchors, 2 floats per each point, x-y format
78 // max is 20 points
80
81} CurveData;
82
83typedef struct
84{
85 // Number of samples to use for the curve.
86 unsigned int m_samplingRes;
87 unsigned int m_outputRes;
88
89 // Sampling array
90 unsigned short int *m_Samples; // jo: changed to short int to save memory
91
93
94/*********************************************
95CurveDataSample:
96 Samples from a spline curve constructed from
97 the curve data.
98
99 curve - Pointer to curve struct to hold the data.
100 sample - Pointer to sample struct to hold the data.
101**********************************************/
102int CurveDataSample(CurveData *curve, CurveSample *sample);
103
104/***************************************************************
105 * interpolate_set:
106 *
107 * convenience function for calculating the necessary parameters for
108 * interpolation.
109 *
110 * input:
111 * n - length of data arrays
112 * x - x axis of the data array
113 * y - y axis of the data array
114 * type - type of interpolation currently either CUBIC or HERMITE
115 * output:
116 * ypp - pointer to array of parameters
117 *******************************************************************/
118float *interpolate_set(int n, float x[], float y[], unsigned int type);
119
120/***************************************************************
121 * interpolate_val:
122 *
123 * convenience function for piecewise interpolation
124 *
125 * input:
126 * n - length of data arrays
127 * x - x axis of the data array
128 * xval - point where to interpolate
129 * y - y axis of the data array
130 * tangents - parameters calculated with interpolate_set
131 * type - type of interpolation currently either CUBIC or HERMITE
132 * output:
133 * yval - interpolated value at xval
134 *******************************************************************/
135float interpolate_val(int n, float x[], float xval, float y[], float tangents[], unsigned int type);
136
137// clang-format off
138// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
139// vim: shiftwidth=2 expandtab tabstop=2 cindent
140// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
141// clang-format on
142
const float n
Definition colorspaces_inline_conversions.h:929
int type
Definition common/metadata.c:62
float * interpolate_set(int n, float x[], float y[], unsigned int type)
Definition curve_tools.c:514
int CurveDataSample(CurveData *curve, CurveSample *sample)
Definition curve_tools.c:677
#define MAX_ANCHORS
Definition curve_tools.h:39
float interpolate_val(int n, float x[], float xval, float y[], float tangents[], unsigned int type)
Definition curve_tools.c:519
static const float x
Definition iop_profile.h:239
Definition curve_tools.h:58
float x
Definition curve_tools.h:59
float y
Definition curve_tools.h:60
Definition curve_tools.h:64
float m_min_x
Definition curve_tools.h:69
float m_max_x
Definition curve_tools.h:70
unsigned char m_numAnchors
Definition curve_tools.h:75
unsigned int m_spline_type
Definition curve_tools.h:66
float m_max_y
Definition curve_tools.h:72
float m_min_y
Definition curve_tools.h:71
Definition curve_tools.h:84
unsigned int m_outputRes
Definition curve_tools.h:87
unsigned int m_samplingRes
Definition curve_tools.h:86
unsigned short int * m_Samples
Definition curve_tools.h:90