Blender V4.3
COM_van_vliet_gaussian_coefficients.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <cstdint>
8#include <memory>
9
10#include "BLI_map.hh"
12
14
16
17class Context;
18
19/* ------------------------------------------------------------------------------------------------
20 * Van Vliet Gaussian Coefficients Key.
21 */
23 public:
24 float sigma;
25
27
28 uint64_t hash() const;
29};
30
33
34/* -------------------------------------------------------------------------------------------------
35 * Van Vliet Gaussian Coefficients.
36 *
37 * A caches resource that computes and caches the coefficients of the fourth order IIR filter
38 * approximating a Gaussian filter computed using Van Vliet's design method. This is based on the
39 * following paper:
40 *
41 * Van Vliet, Lucas J., Ian T. Young, and Piet W. Verbeek. "Recursive Gaussian derivative
42 * filters." Proceedings. Fourteenth International Conference on Pattern Recognition (Cat. No.
43 * 98EX170). Vol. 1. IEEE, 1998.
44 *
45 * However, to improve the numerical stability of the filter, it is decomposed into a bank of
46 * two parallel second order IIR filters, each having a causal and a non causal filter. */
48 private:
49 /* The causal and non causal feedforward coefficients for the first second-order filter. */
50 double2 first_causal_feedforward_coefficients_;
51 double2 first_non_causal_feedforward_coefficients_;
52 /* The feedback coefficients for the first second order filter. This is the same for both the
53 * causal and non causal filters. */
54 double2 first_feedback_coefficients_;
55
56 /* The causal and non causal feedforward coefficients for the second second-order filter. */
57 double2 second_causal_feedforward_coefficients_;
58 double2 second_non_causal_feedforward_coefficients_;
59 /* The feedback coefficients for the second second-order filter. This is the same for both the
60 * causal and non causal filters. */
61 double2 second_feedback_coefficients_;
62
63 /* The difference equation of the IIR filter rely on previous outputs to compute the new output,
64 * and those previous outputs need to be properly initialized somehow. To do Neumann boundary
65 * condition, we multiply the boundary value with this coefficient to simulate an infinite stream
66 * of the boundary value. See the implementation for more information. */
67 double first_causal_boundary_coefficient_;
68 double first_non_causal_boundary_coefficient_;
69 double second_causal_boundary_coefficient_;
70 double second_non_causal_boundary_coefficient_;
71
72 public:
73 VanVlietGaussianCoefficients(Context &context, float sigma);
74
78
82
87};
88
89/* ------------------------------------------------------------------------------------------------
90 * Van Vliet Gaussian Coefficients Container.
91 */
93 private:
95
96 public:
97 void reset() override;
98
99 /* Check if there is an available VanVlietGaussianCoefficients cached resource with the given
100 * parameters in the container, if one exists, return it, otherwise, return a newly created one
101 * and add it to the container. In both cases, tag the cached resource as needed to keep it
102 * cached for the next evaluation. */
103 VanVlietGaussianCoefficients &get(Context &context, float sigma);
104};
105
106} // namespace blender::realtime_compositor
VanVlietGaussianCoefficients & get(Context &context, float sigma)
local_group_size(16, 16) .push_constant(Type b
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
unsigned __int64 uint64_t
Definition stdint.h:90