Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
data/kernels/rgb_norms.h
Go to the documentation of this file.
1/*
2 * This file is part of darktable,
3 * Copyright (C) 2019-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
29
30static inline float
31dt_rgb_norm(const float4 in, const int norm, const int work_profile,
32 constant dt_colorspaces_iccprofile_info_cl_t *profile_info, read_only image2d_t lut)
33{
34 if (norm == DT_RGB_NORM_LUMINANCE)
35 {
36 return (work_profile == 0) ? dt_camera_rgb_luminance(in): get_rgb_matrix_luminance(in, profile_info, profile_info->matrix_in, lut);
37 }
38 else if (norm == DT_RGB_NORM_MAX)
39 {
40 return max(in.x, max(in.y, in.z));
41 }
42 else if (norm == DT_RGB_NORM_AVERAGE)
43 {
44 return (in.x + in.y + in.z) / 3.0f;
45 }
46 else if (norm == DT_RGB_NORM_SUM)
47 {
48 return in.x + in.y + in.z;
49 }
50 else if (norm == DT_RGB_NORM_NORM)
51 {
52 return native_powr(in.x * in.x + in.y * in.y + in.z * in.z, 0.5f);
53 }
54 else if (norm == DT_RGB_NORM_POWER)
55 {
56 float R, G, B;
57 R = in.x * in.x;
58 G = in.y * in.y;
59 B = in.z * in.z;
60 return (in.x * R + in.y * G + in.z * B) / (R + G + B);
61 }
62 else return (in.x + in.y + in.z) / 3.0f;
63}
64
65// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
66// vim: shiftwidth=2 expandtab tabstop=2 cindent
67// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
static float dt_camera_rgb_luminance(const float4 rgb)
Definition color_conversion.h:152
static float get_rgb_matrix_luminance(const float4 rgb, constant const dt_colorspaces_iccprofile_info_cl_t *const profile_info, constant const float *const matrix, read_only image2d_t lut)
Definition color_conversion.h:116
#define B(y, x)
Definition colorspaces.c:149
static float dt_rgb_norm(const float4 in, const int norm, const int work_profile, constant dt_colorspaces_iccprofile_info_cl_t *profile_info, read_only image2d_t lut)
Definition data/kernels/rgb_norms.h:31
dt_iop_rgb_norms_t
Definition data/kernels/rgb_norms.h:20
@ DT_RGB_NORM_AVERAGE
Definition data/kernels/rgb_norms.h:24
@ DT_RGB_NORM_NORM
Definition data/kernels/rgb_norms.h:26
@ DT_RGB_NORM_NONE
Definition data/kernels/rgb_norms.h:21
@ DT_RGB_NORM_LUMINANCE
Definition data/kernels/rgb_norms.h:22
@ DT_RGB_NORM_SUM
Definition data/kernels/rgb_norms.h:25
@ DT_RGB_NORM_POWER
Definition data/kernels/rgb_norms.h:27
@ DT_RGB_NORM_MAX
Definition data/kernels/rgb_norms.h:23
#define R
Definition color_conversion.h:36