FFmpeg
edge_common.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /**
20  * @file
21  * common functions for edge detection
22  */
23 
24 #ifndef AVFILTER_EDGE_COMMON_H
25 #define AVFILTER_EDGE_COMMON_H
26 
27 #include "avfilter.h"
28 
29 /**
30  * @brief Rounded directions used in av_image_sobel()
31  */
37 };
38 
39 /**
40  * Simple sobel operator to get rounded gradients
41  *
42  * @param w the width of the image in pixels
43  * @param h the height of the image in pixels
44  * @param dst data pointers to magnitude image
45  * @param dst_linesize linesizes for the magnitude image
46  * @param dir data pointers to direction image
47  * @param dir_linesize linesizes for the direction image
48  * @param src data pointers to source image
49  * @param src_linesize linesizes for the source image
50  */
51 #define PROTO_SOBEL(depth) \
52 void ff_sobel_##depth(int w, int h, \
53  uint16_t *dst, int dst_linesize, \
54  int8_t *dir, int dir_linesize, \
55  const uint8_t *src, int src_linesize, int src_stride);
56 
57 PROTO_SOBEL(8)
58 PROTO_SOBEL(16)
59 
60 /**
61  * Filters rounded gradients to drop all non-maxima pixels in the magnitude image
62  * Expects gradients generated by av_image_sobel()
63  * Expects zero's in the destination buffer dst
64  *
65  * @param w the width of the image in pixels
66  * @param h the height of the image in pixels
67  * @param dst data pointers to magnitude image
68  * @param dst_linesize linesizes for the magnitude image
69  * @param dir data pointers to direction image
70  * @param dir_linesize linesizes for the direction image
71  * @param src data pointers to source image
72  * @param src_linesize linesizes for the source image
73  */
74 void ff_non_maximum_suppression(int w, int h,
75  uint8_t *dst, int dst_linesize,
76  const int8_t *dir, int dir_linesize,
77  const uint16_t *src, int src_linesize);
78 
79 /**
80  * Filters all pixels in src to keep all pixels > high,
81  * and keep all pixels > low where all surrounding pixels > high
82  *
83  * @param low the low threshold value
84  * @param high the hegh threshold value
85  * @param w the width of the image in pixels
86  * @param h the height of the image in pixels
87  * @param dst data pointers to destination image
88  * @param dst_linesize linesizes for the destination image
89  * @param src data pointers to source image
90  * @param src_linesize linesizes for the source image
91  */
92 void ff_double_threshold(int low, int high, int w, int h,
93  uint8_t *dst, int dst_linesize,
94  const uint8_t *src, int src_linesize);
95 
96 /**
97  * Applies gaussian blur.
98  * 5x5 kernels, sigma = 1.4
99  *
100  * @param w the width of the image in pixels
101  * @param h the height of the image in pixels
102  * @param dst data pointers to destination image
103  * @param dst_linesize linesizes for the destination image
104  * @param src data pointers to source image
105  * @param src_linesize linesizes for the source image
106  */
107 #define PROTO_GAUSSIAN_BLUR(depth) \
108 void ff_gaussian_blur_##depth(int w, int h, \
109  uint8_t *dst, int dst_linesize, \
110  const uint8_t *src, int src_linesize, int src_stride);
111 
114 
115 #endif
AVRoundedDirection
AVRoundedDirection
Rounded directions used in av_image_sobel()
Definition: edge_common.h:32
ff_double_threshold
void ff_double_threshold(int low, int high, int w, int h, uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize)
Filters all pixels in src to keep all pixels > high, and keep all pixels > low where all surrounding ...
Definition: edge_common.c:89
w
uint8_t w
Definition: llviddspenc.c:38
high
int high
Definition: dovi_rpuenc.c:38
DIRECTION_VERTICAL
@ DIRECTION_VERTICAL
Definition: edge_common.h:36
DIRECTION_45DOWN
@ DIRECTION_45DOWN
Definition: edge_common.h:34
ff_non_maximum_suppression
void ff_non_maximum_suppression(int w, int h, uint8_t *dst, int dst_linesize, const int8_t *dir, int dir_linesize, const uint16_t *src, int src_linesize)
Filters rounded gradients to drop all non-maxima pixels in the magnitude image Expects gradients gene...
Definition: edge_common.c:60
PROTO_SOBEL
#define PROTO_SOBEL(depth)
Simple sobel operator to get rounded gradients.
Definition: edge_common.h:51
DIRECTION_HORIZONTAL
@ DIRECTION_HORIZONTAL
Definition: edge_common.h:35
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
PROTO_GAUSSIAN_BLUR
#define PROTO_GAUSSIAN_BLUR(depth)
Applies gaussian blur.
Definition: edge_common.h:107
avfilter.h
DIRECTION_45UP
@ DIRECTION_45UP
Definition: edge_common.h:33
h
h
Definition: vp9dsp_template.c:2070
src
#define src
Definition: vp8dsp.c:248