Debian Codegraph @

src/utils/kernel.h

raw symbols SCIP
1 // SPDX-License-Identifier: MPL-2.0
2 // Copyright (c) Yuxuan Shui <[email protected]>
3
4 #pragma once
5 #include <stdlib.h>
6 #include "compiler.h"
7
8 /// Code for generating convolution kernels
9
10 typedef struct conv {
11 int w, h;
12 double *rsum;
13 double data[];
14 } conv;
15
16 /// Calculate the sum of a rectangle part of the convolution kernel
17 /// the rectangle is defined by top left (x, y), and a size (width x height)
18 double attr_pure sum_kernel(const conv *map, int x, int y, int width, int height);
19 double attr_pure sum_kernel_normalized(const conv *map, int x, int y, int width, int height);
20
21 /// Create a kernel with gaussian distribution with standard deviation `r`, and size
22 /// `size`.
23 conv *gaussian_kernel(double r, int size);
24
25 /// Estimate the best standard deviation for a give kernel size.
26 double gaussian_kernel_std_for_size(double size, double row_limit);
27
28 /// Create a gaussian kernel with auto detected standard deviation. The choosen standard
29 /// deviation tries to make sure the outer most pixels of the shadow are completely
30 /// transparent.
31 ///
32 /// @param[in] shadow_radius the radius of the shadow
33 conv *gaussian_kernel_autodetect_deviation(double shadow_radius);
34
35 /// preprocess kernels to make shadow generation faster
36 /// shadow_sum[x*d+y] is the sum of the kernel from (0, 0) to (x, y), inclusive
37 void sum_kernel_preprocess(conv *map);
38
39 static inline void free_conv(conv *k) {
40 free(k->rsum);
41 free(k);
42 }