GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_median.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2/*
3 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz>
4 */
5
6 /*
7
8 Constant time Median Filter (the computational complexity is independent of
9 radius).
10
11 The xmed and ymed are radius values for x and y. The algorithm uses xmed
12 respectively ymed pixel neighbors from each side so the result is median of
13 rectangle of 2 * xmed + 1 x 2 * ymed + 1 pixels.
14
15 */
16
17#ifndef FILTERS_GP_MEDIAN_H
18#define FILTERS_GP_MEDIAN_H
19
20#include <filters/gp_filter.h>
21
22int gp_filter_median_ex(const gp_pixmap *src,
23 gp_coord x_src, gp_coord y_src,
24 gp_size w_src, gp_size h_src,
25 gp_pixmap *dst,
26 gp_coord x_dst, gp_coord y_dst,
27 int xmed, int ymed,
28 gp_progress_cb *callback);
29
30gp_pixmap *gp_filter_median_ex_alloc(const gp_pixmap *src,
31 gp_coord x_src, gp_coord y_src,
32 gp_size w_src, gp_size h_src,
33 int xmed, int ymed,
34 gp_progress_cb *callback);
35
36static inline int gp_filter_median(const gp_pixmap *src,
37 gp_pixmap *dst,
38 int xmed, int ymed,
39 gp_progress_cb *callback)
40{
41 return gp_filter_median_ex(src, 0, 0, src->w, src->h,
42 dst, 0, 0, xmed, ymed, callback);
43}
44
45static inline gp_pixmap *gp_filter_median_alloc(const gp_pixmap *src,
46 int xmed, int ymed,
47 gp_progress_cb *callback)
48{
49 return gp_filter_median_ex_alloc(src, 0, 0, src->w, src->h,
50 xmed, ymed, callback);
51}
52
53#endif /* FILTERS_GP_MEDIAN_H */
int gp_coord
Integer type for coordinates i.e. x, y, ...
Definition gp_types.h:19
unsigned int gp_size
Integer type for sizes i.e. w, h, ...
Definition gp_types.h:24
Common filter includes.
A pixmap buffer.
Definition gp_pixmap.h:33
uint32_t h
Pixmap height in pixels.
Definition gp_pixmap.h:46
uint32_t w
Pixmap width in pixels.
Definition gp_pixmap.h:44
Progress callback.