• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
32 enum AVRoundedDirection {
33     DIRECTION_45UP,
34     DIRECTION_45DOWN,
35     DIRECTION_HORIZONTAL,
36     DIRECTION_VERTICAL,
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 void ff_sobel(int w, int h,
52               uint16_t *dst, int dst_linesize,
53               int8_t *dir, int dir_linesize,
54               const uint8_t *src, int src_linesize);
55 
56 /**
57  * Filters rounded gradients to drop all non-maxima pixels in the magnitude image
58  * Expects gradients generated by av_image_sobel()
59  * Expects zero's in the destination buffer dst
60  *
61  * @param w             the width of the image in pixels
62  * @param h             the height of the image in pixels
63  * @param dst           data pointers to magnitude image
64  * @param dst_linesize  linesizes for the magnitude image
65  * @param dir           data pointers to direction image
66  * @param dir_linesize  linesizes for the direction image
67  * @param src           data pointers to source image
68  * @param src_linesize  linesizes for the source image
69  */
70 void ff_non_maximum_suppression(int w, int h,
71                                 uint8_t *dst, int dst_linesize,
72                                 const int8_t *dir, int dir_linesize,
73                                 const uint16_t *src, int src_linesize);
74 
75 /**
76  * Filters all pixels in src to keep all pixels > high,
77  * and keep all pixels > low where all surrounding pixels > high
78  *
79  * @param low           the low threshold value
80  * @param high          the hegh threshold value
81  * @param w             the width of the image in pixels
82  * @param h             the height of the image in pixels
83  * @param dst           data pointers to destination image
84  * @param dst_linesize  linesizes for the destination image
85  * @param src           data pointers to source image
86  * @param src_linesize  linesizes for the source image
87  */
88 void ff_double_threshold(int low, int high, int w, int h,
89                          uint8_t *dst, int dst_linesize,
90                          const uint8_t *src, int src_linesize);
91 
92 /**
93  * Applies gaussian blur.
94  * 5x5 kernels, sigma = 1.4
95  *
96  * @param w             the width of the image in pixels
97  * @param h             the height of the image in pixels
98  * @param dst           data pointers to destination image
99  * @param dst_linesize  linesizes for the destination image
100  * @param src           data pointers to source image
101  * @param src_linesize  linesizes for the source image
102  */
103 void ff_gaussian_blur(int w, int h,
104                       uint8_t *dst, int dst_linesize,
105                       const uint8_t *src, int src_linesize);
106 
107 #endif
108