Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
guided_filter.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2011 johannes hanika.
4 Copyright (C) 2012 Richard Wonka.
5 Copyright (C) 2016 Roman Lebedev.
6 Copyright (C) 2016 Tobias Ellinghaus.
7 Copyright (C) 2017-2019 Heiko Bauke.
8 Copyright (C) 2017 Peter Budai.
9 Copyright (C) 2020 Hubert Kowalski.
10 Copyright (C) 2020-2021 Pascal Obry.
11 Copyright (C) 2020-2021 Ralf Brown.
12 Copyright (C) 2020 Robert Bridge.
13 Copyright (C) 2022 Martin Bařinka.
14 Copyright (C) 2024 Alynx Zhou.
15 Copyright (C) 2025-2026 Aurélien PIERRE.
16
17 darktable is free software: you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published by
19 the Free Software Foundation, either version 3 of the License, or
20 (at your option) any later version.
21
22 darktable is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with darktable. If not, see <http://www.gnu.org/licenses/>.
29*/
30
31#pragma once
32
33#include "common/darktable.h"
34
35#include "common/darktable.h"
36#include "common/opencl.h"
37
38struct dt_iop_roi_t;
39
40// buffer to store single-channel image along with its dimensions
41typedef struct gray_image
42{
43 float *data;
46
47
48// allocate space for 1-component image of size width x height
49// FIXME: the code consuming gray_image doesn't check if we actually allocated the buffer
50static inline int new_gray_image(gray_image *img, int width, int height)
51{
53 if(IS_NULL_PTR(img->data)) return 1;
54 img->width = width;
55 img->height = height;
56 return 0;
57}
58
59
60// free space for 1-component image
61static inline void free_gray_image(gray_image *img_p)
62{
64 img_p->data = NULL;
65}
66
67
68// copy 1-component image img1 to img2
69static inline void copy_gray_image(gray_image img1, gray_image img2)
70{
71 memcpy(img2.data, img1.data, sizeof(float) * img1.width * img1.height);
72}
73
74
75// minimum of two integers
76static inline int min_i(int a, int b)
77{
78 return a < b ? a : b;
79}
80
81
82// maximum of two integers
83static inline int max_i(int a, int b)
84{
85 return a > b ? a : b;
86}
87
88int guided_filter(const float *guide, const float *in, float *out, int width, int height, int ch, int w,
89 float sqrt_eps, float guide_weight, float min, float max);
90
91#ifdef HAVE_OPENCL
92
104
105
107
109
110int guided_filter_cl(int devid, cl_mem guide, cl_mem in, cl_mem out, int width, int height, int ch, int w,
111 float sqrt_eps, float guide_weight, float min, float max);
112
113#endif
114// clang-format off
115// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
116// vim: shiftwidth=2 expandtab tabstop=2 cindent
117// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
118// clang-format on
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
const float g
Definition colorspaces_inline_conversions.h:674
static const float const float const float min
Definition colorspaces_inline_conversions.h:438
const float max
Definition colorspaces_inline_conversions.h:490
const dt_colormatrix_t dt_aligned_pixel_t out
Definition colorspaces_inline_conversions.h:42
#define dt_pixelpipe_cache_alloc_align_float_cache(pixels, id)
Definition darktable.h:447
#define dt_pixelpipe_cache_free_align(mem)
Definition darktable.h:453
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
Definition darktable.h:281
int guided_filter(const float *guide, const float *in, float *out, int width, int height, int ch, int w, float sqrt_eps, float guide_weight, float min, float max)
Definition guided_filter.c:351
dt_guided_filter_cl_global_t * dt_guided_filter_init_cl_global()
Definition guided_filter.c:382
static void copy_gray_image(gray_image img1, gray_image img2)
Definition guided_filter.h:69
static int max_i(int a, int b)
Definition guided_filter.h:83
static int new_gray_image(gray_image *img, int width, int height)
Definition guided_filter.h:50
static int min_i(int a, int b)
Definition guided_filter.h:76
void dt_guided_filter_free_cl_global(dt_guided_filter_cl_global_t *g)
Definition guided_filter.c:399
static void free_gray_image(gray_image *img_p)
Definition guided_filter.h:61
int guided_filter_cl(int devid, cl_mem guide, cl_mem in, cl_mem out, int width, int height, int ch, int w, float sqrt_eps, float guide_weight, float min, float max)
Definition guided_filter.c:746
float *const restrict const size_t const size_t ch
Definition luminance_mask.h:78
Definition guided_filter.h:94
int kernel_guided_filter_guided_filter_covariances
Definition guided_filter.h:98
int kernel_guided_filter_box_mean_x
Definition guided_filter.h:96
int kernel_guided_filter_solve
Definition guided_filter.h:101
int kernel_guided_filter_generate_result
Definition guided_filter.h:102
int kernel_guided_filter_box_mean_y
Definition guided_filter.h:97
int kernel_guided_filter_update_covariance
Definition guided_filter.h:100
int kernel_guided_filter_guided_filter_variances
Definition guided_filter.h:99
int kernel_guided_filter_split_rgb
Definition guided_filter.h:95
Region of interest passed through the pixelpipe.
Definition imageop.h:72
Definition guided_filter.h:42
float * data
Definition guided_filter.h:43
int width
Definition guided_filter.h:44
int height
Definition guided_filter.h:44