2018-12-16 05:11:41 +08:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) Yuxuan Shui <yshuiv7@gmail.com>
|
|
|
|
|
|
|
|
#pragma once
|
2018-12-20 04:50:02 +08:00
|
|
|
#include "compiler.h"
|
2018-12-16 05:11:41 +08:00
|
|
|
|
|
|
|
/// Code for generating convolution kernels
|
|
|
|
|
|
|
|
typedef struct conv {
|
2018-12-20 04:50:02 +08:00
|
|
|
int size;
|
|
|
|
double data[];
|
2018-12-16 05:11:41 +08:00
|
|
|
} conv;
|
|
|
|
|
|
|
|
/// Calculate the sum of a rectangle part of the convolution kernel
|
|
|
|
/// the rectangle is defined by top left (x, y), and a size (width x height)
|
2018-12-20 04:50:02 +08:00
|
|
|
double attr_const attr_pure sum_kernel(const conv *map, int x, int y, int width,
|
|
|
|
int height);
|
2018-12-16 05:11:41 +08:00
|
|
|
|
|
|
|
/// Create a kernel with gaussian distribution of radius r
|
|
|
|
conv *gaussian_kernel(double r);
|