Skip to content

Commit 764238e

Browse files
committed
FEAT: Adding separable convolution for 2D images
1 parent 563e39f commit 764238e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

arrayfire/signal.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,37 @@ def convolve2(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_
923923
conv_mode.value, conv_domain.value))
924924
return output
925925

926+
def convolve2_separable(col_kernel, row_kernel, signal, conv_mode = CONV_MODE.DEFAULT):
927+
"""
928+
Convolution: 2D separable convolution
929+
930+
Parameters
931+
-----------
932+
933+
col_kernel: af.Array
934+
- A column vector to be applied along each column of `signal`
935+
936+
row_kernel: af.Array
937+
- A row vector to be applied along each row of `signal`
938+
939+
signal: af.Array
940+
- A 2 dimensional signal or batch of 2 dimensional signals.
941+
942+
conv_mode: optional: af.CONV_MODE. default: af.CONV_MODE.DEFAULT.
943+
- Specifies if the output does full convolution (af.CONV_MODE.EXPAND) or
944+
maintains the same size as input (af.CONV_MODE.DEFAULT).
945+
Returns
946+
--------
947+
948+
output: af.Array
949+
- Output of 2D sepearable convolution.
950+
"""
951+
output = Array()
952+
safe_call(backend.get().af_convolve2_sep(ct.pointer(output.arr),
953+
col_kernel.arr, row_kernel.arr,signal.arr,
954+
conv_mode.value))
955+
return output
956+
926957
def convolve3(signal, kernel, conv_mode = CONV_MODE.DEFAULT, conv_domain = CONV_DOMAIN.AUTO):
927958
"""
928959
Convolution: 3D

0 commit comments

Comments
 (0)