Skip to content

Commit d7d25e8

Browse files
committed
Fix bug in Canny
1 parent de788f9 commit d7d25e8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

arrayfire/image.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ def moments(image, moment = MOMENT.FIRST_ORDER):
11961196

11971197
def canny(image,
11981198
low_threshold, high_threshold = None,
1199-
treshold_type = CANNY_THRESHOLD.MANUAL,
1199+
threshold_type = CANNY_THRESHOLD.MANUAL,
12001200
sobel_window = 3, is_fast = False):
12011201
"""
12021202
Canny edge detector.
@@ -1230,9 +1230,14 @@ def canny(image,
12301230
12311231
"""
12321232
output = Array()
1233-
safe_call(backend.get().af_canny(c_pointer(output.arr), threshold_type.value,
1234-
low_threshold, high_threshold and high_threshold.value or 0,
1235-
c_uint(sobel_window), c_bool(is_fast)))
1233+
if threshold_type.value == CANNY_THRESHOLD.MANUAL.value:
1234+
assert(high_threshold is not None)
1235+
1236+
high_threshold = high_threshold if high_threshold else 0
1237+
safe_call(backend.get().af_canny(c_pointer(output.arr), image.arr,
1238+
c_int_t(threshold_type.value),
1239+
c_float_t(low_threshold), c_float_t(high_threshold),
1240+
c_uint_t(sobel_window), c_bool_t(is_fast)))
12361241
return output
12371242

12381243
def is_image_io_available():

arrayfire/tests/simple/image.py

+3
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,7 @@ def simple_image(verbose = False):
7878
display_func(af.rgb2ycbcr(a))
7979
display_func(af.ycbcr2rgb(a))
8080

81+
a = af.randu(10, 10)
82+
b = af.canny(a, low_threshold = 0.2, high_threshold = 0.8)
83+
8184
_util.tests['image'] = simple_image

0 commit comments

Comments
 (0)