aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValery Kot <valery.kot@gmail.com>2020-06-22 17:29:21 +0200
committerAndriy Gelman <andriy.gelman@gmail.com>2020-07-06 23:20:53 -0400
commit855d51bf481dddf425f9a82e4d1aa2cdc93c22f8 (patch)
tree6a5829f3fdce2cbc3e043a6e5655564f5e1005bf
parent235a5734e084f2746b4c133bf33cb4579a6ca17f (diff)
downloadffmpeg-855d51bf481dddf425f9a82e4d1aa2cdc93c22f8.tar.gz
avfilter/vf_edgedetect: properly implement double_threshold()
Important part of this algorithm is the double threshold step: pixels above "high" threshold being kept, pixels below "low" threshold dropped, pixels in between (weak edges) are kept if they are neighboring "high" pixels. The weak edge check uses a neighboring context and should not be applied on the plane's border. The condition was incorrect and has been fixed in the commit. Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
-rw-r--r--libavfilter/vf_edgedetect.c2
-rw-r--r--tests/ref/fate/filter-edgedetect2
-rw-r--r--tests/ref/fate/filter-edgedetect-colormix2
3 files changed, 3 insertions, 3 deletions
diff --git a/libavfilter/vf_edgedetect.c b/libavfilter/vf_edgedetect.c
index a5614ea63b..df8afbd532 100644
--- a/libavfilter/vf_edgedetect.c
+++ b/libavfilter/vf_edgedetect.c
@@ -294,7 +294,7 @@ static void double_threshold(int low, int high, int w, int h,
continue;
}
- if ((!i || i == w - 1 || !j || j == h - 1) &&
+ if (!(!i || i == w - 1 || !j || j == h - 1) &&
src[i] > low &&
(src[-src_linesize + i-1] > high ||
src[-src_linesize + i ] > high ||
diff --git a/tests/ref/fate/filter-edgedetect b/tests/ref/fate/filter-edgedetect
index 23c9953e61..e49639afac 100644
--- a/tests/ref/fate/filter-edgedetect
+++ b/tests/ref/fate/filter-edgedetect
@@ -1 +1 @@
-edgedetect 93ceace33f6636bcdbeb037317c65745
+edgedetect 04ff46bb35edff3dbad4102391516d25
diff --git a/tests/ref/fate/filter-edgedetect-colormix b/tests/ref/fate/filter-edgedetect-colormix
index e828c6bd19..0df17344bc 100644
--- a/tests/ref/fate/filter-edgedetect-colormix
+++ b/tests/ref/fate/filter-edgedetect-colormix
@@ -1 +1 @@
-edgedetect-colormix 1b8658252e2f03fbae30e6d63dd24c7c
+edgedetect-colormix 9f50c5586f899a8f5a10059154d64bde