Go to the documentation of this file.
35 int tanpi8gx, tan3pi8gx;
40 tanpi8gx = 27146 * gx;
41 tan3pi8gx = 158218 * gx;
51 uint16_t *dst,
int dst_linesize,
52 int8_t *dir,
int dir_linesize,
53 const uint8_t *
src,
int src_linesize)
57 for (j = 1; j <
h - 1; j++) {
61 for (
i = 1;
i <
w - 1;
i++) {
63 -1*
src[-src_linesize +
i-1] + 1*
src[-src_linesize +
i+1]
65 -1*
src[ src_linesize +
i-1] + 1*
src[ src_linesize +
i+1];
67 -1*
src[-src_linesize +
i-1] + 1*
src[ src_linesize +
i-1]
68 -2*
src[-src_linesize +
i ] + 2*
src[ src_linesize +
i ]
69 -1*
src[-src_linesize +
i+1] + 1*
src[ src_linesize +
i+1];
81 uint8_t *dst,
int dst_linesize,
82 const int8_t *dir,
int dir_linesize,
83 const uint16_t *
src,
int src_linesize)
87 #define COPY_MAXIMA(ay, ax, by, bx) do { \
88 if (src[i] > src[(ay)*src_linesize + i+(ax)] && \
89 src[i] > src[(by)*src_linesize + i+(bx)]) \
90 dst[i] = av_clip_uint8(src[i]); \
93 for (j = 1; j <
h - 1; j++) {
97 for (
i = 1;
i <
w - 1;
i++) {
110 uint8_t *dst,
int dst_linesize,
111 const uint8_t *
src,
int src_linesize)
115 for (j = 0; j <
h; j++) {
116 for (
i = 0;
i <
w;
i++) {
122 if (!(!
i ||
i ==
w - 1 || !j || j ==
h - 1) &&
124 (
src[-src_linesize +
i-1] > high ||
125 src[-src_linesize +
i ] > high ||
126 src[-src_linesize +
i+1] > high ||
129 src[ src_linesize +
i-1] > high ||
130 src[ src_linesize +
i ] > high ||
131 src[ src_linesize +
i+1] > high))
143 uint8_t *dst,
int dst_linesize,
144 const uint8_t *
src,
int src_linesize)
148 memcpy(dst,
src,
w); dst += dst_linesize;
src += src_linesize;
149 memcpy(dst,
src,
w); dst += dst_linesize;
src += src_linesize;
150 for (j = 2; j <
h - 2; j++) {
153 for (
i = 2;
i <
w - 2;
i++) {
155 dst[
i] = ((
src[-2*src_linesize +
i-2] +
src[2*src_linesize +
i-2]) * 2
156 + (
src[-2*src_linesize +
i-1] +
src[2*src_linesize +
i-1]) * 4
157 + (
src[-2*src_linesize +
i ] +
src[2*src_linesize +
i ]) * 5
158 + (
src[-2*src_linesize +
i+1] +
src[2*src_linesize +
i+1]) * 4
159 + (
src[-2*src_linesize +
i+2] +
src[2*src_linesize +
i+2]) * 2
161 + (
src[ -src_linesize +
i-2] +
src[ src_linesize +
i-2]) * 4
162 + (
src[ -src_linesize +
i-1] +
src[ src_linesize +
i-1]) * 9
163 + (
src[ -src_linesize +
i ] +
src[ src_linesize +
i ]) * 12
164 + (
src[ -src_linesize +
i+1] +
src[ src_linesize +
i+1]) * 9
165 + (
src[ -src_linesize +
i+2] +
src[ src_linesize +
i+2]) * 4
171 +
src[
i+2] * 5) / 159;
174 dst[
i + 1] =
src[
i + 1];
179 memcpy(dst,
src,
w); dst += dst_linesize;
src += src_linesize;
void ff_gaussian_blur(int w, int h, uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize)
Applies gaussian blur.
void ff_sobel(int w, int h, uint16_t *dst, int dst_linesize, int8_t *dir, int dir_linesize, const uint8_t *src, int src_linesize)
Simple sobel operator to get rounded gradients.
static int get_rounded_direction(int gx, int gy)
#define COPY_MAXIMA(ay, ax, by, bx)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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...
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 ...
#define i(width, name, range_min, range_max)