Blender V5.0
COM_algorithm_parallel_reduction.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
9#include "COM_context.hh"
10#include "COM_result.hh"
11
12namespace blender::compositor {
13
14/* --------------------------------------------------------------------
15 * Sum Reductions.
16 */
17
18/* Computes the sum of the red channel of all pixels in the given result. */
19float sum_red(Context &context, const Result &result);
20
21/* Computes the sum of the green channel of all pixels in the given result. */
22float sum_green(Context &context, const Result &result);
23
24/* Computes the sum of the blue channel of all pixels in the given result. */
25float sum_blue(Context &context, const Result &result);
26
27/* Computes the sum of the luminance of all pixels in the given result, using the given luminance
28 * coefficients to compute the luminance. */
29float sum_luminance(Context &context, const Result &result, const float3 &luminance_coefficients);
30
31/* Computes the sum of the logarithm of the luminance of all pixels in the given result, using the
32 * given luminance coefficients to compute the luminance. */
33float sum_log_luminance(Context &context,
34 const Result &result,
35 const float3 &luminance_coefficients);
36
37/* Computes the sum of the colors of all pixels in the given result. */
38float4 sum_color(Context &context, const Result &result);
39
40/* --------------------------------------------------------------------
41 * Sum Of Squared Difference Reductions.
42 */
43
44/* Computes the sum of the squared difference between the red channel of all pixels in the given
45 * result and the given subtrahend. This can be used to compute the standard deviation if the
46 * given subtrahend is the mean. */
47float sum_red_squared_difference(Context &context, const Result &result, const float subtrahend);
48
49/* Computes the sum of the squared difference between the green channel of all pixels in the given
50 * result and the given subtrahend. This can be used to compute the standard deviation if the
51 * given subtrahend is the mean. */
52float sum_green_squared_difference(Context &context, const Result &result, const float subtrahend);
53
54/* Computes the sum of the squared difference between the blue channel of all pixels in the given
55 * result and the given subtrahend. This can be used to compute the standard deviation if the
56 * given subtrahend is the mean. */
57float sum_blue_squared_difference(Context &context, const Result &result, const float subtrahend);
58
59/* Computes the sum of the squared difference between the luminance of all pixels in the given
60 * result and the given subtrahend, using the given luminance coefficients to compute the
61 * luminance. This can be used to compute the standard deviation if the given subtrahend is the
62 * mean. */
64 const Result &result,
65 const float3 &luminance_coefficients,
66 const float subtrahend);
67
68/* --------------------------------------------------------------------
69 * Maximum Reductions.
70 */
71
72/* Computes the maximum luminance of all pixels in the given result, using the given luminance
73 * coefficients to compute the luminance. */
74float maximum_luminance(Context &context,
75 const Result &result,
76 const float3 &luminance_coefficients);
77
78/* Computes the maximum float value of all pixels in the given result. */
79float maximum_float(Context &context, const Result &result);
80
81/* Computes the maximum float2 value of all pixels in the given result. */
82float2 maximum_float2(Context &context, const Result &result);
83
84/* Computes the maximum float of all pixels in the given float result, limited to the given range.
85 * Values outside of the given range are ignored. If non of the pixel values are in the range, the
86 * lower bound of the range is returned. For instance, if the given range is [-10, 10] and the
87 * image contains the values {2, 5, 11}, the maximum will be 5, since 11 is outside of the range.
88 * This is particularly useful for Z Depth normalization, since Z Depth can contain near infinite
89 * values, so enforcing an upper bound is beneficial. */
90float maximum_float_in_range(Context &context,
91 const Result &result,
92 const float lower_bound,
93 const float upper_bound);
94
95/* --------------------------------------------------------------------
96 * Minimum Reductions.
97 */
98
99/* Computes the minimum luminance of all pixels in the given result, using the given luminance
100 * coefficients to compute the luminance. */
101float minimum_luminance(Context &context,
102 const Result &result,
103 const float3 &luminance_coefficients);
104
105/* Computes the minimum float value of all pixels in the given result. */
106float minimum_float(Context &context, const Result &result);
107
108/* Computes the minimum float of all pixels in the given float result, limited to the given range.
109 * Values outside of the given range are ignored. If non of the pixel values are in the range, the
110 * upper bound of the range is returned. For instance, if the given range is [-10, 10] and the
111 * image contains the values {-11, 2, 5}, the minimum will be 2, since -11 is outside of the range.
112 * This is particularly useful for Z Depth normalization, since Z Depth can contain near infinite
113 * values, so enforcing a lower bound is beneficial. */
114float minimum_float_in_range(Context &context,
115 const Result &result,
116 const float lower_bound,
117 const float upper_bound);
118
119} // namespace blender::compositor
float sum_red(Context &context, const Result &result)
float4 sum_color(Context &context, const Result &result)
float maximum_luminance(Context &context, const Result &result, const float3 &luminance_coefficients)
float sum_red_squared_difference(Context &context, const Result &result, const float subtrahend)
float sum_luminance(Context &context, const Result &result, const float3 &luminance_coefficients)
float sum_blue_squared_difference(Context &context, const Result &result, const float subtrahend)
float sum_luminance_squared_difference(Context &context, const Result &result, const float3 &luminance_coefficients, const float subtrahend)
float minimum_float_in_range(Context &context, const Result &result, const float lower_bound, const float upper_bound)
float maximum_float_in_range(Context &context, const Result &result, const float lower_bound, const float upper_bound)
float sum_green_squared_difference(Context &context, const Result &result, const float subtrahend)
float minimum_float(Context &context, const Result &result)
float sum_green(Context &context, const Result &result)
float minimum_luminance(Context &context, const Result &result, const float3 &luminance_coefficients)
float sum_blue(Context &context, const Result &result)
float2 maximum_float2(Context &context, const Result &result)
float maximum_float(Context &context, const Result &result)
float sum_log_luminance(Context &context, const Result &result, const float3 &luminance_coefficients)
VecBase< float, 4 > float4
VecBase< float, 2 > float2
VecBase< float, 3 > float3