@@ -1265,6 +1265,97 @@ def iir(B, A, X):
12651265 safe_call (backend .get ().af_iir (ct .pointer (Y .arr ), B .arr , A .arr , X .arr ))
12661266 return Y
12671267
1268+ def medfilt (signal , w0 = 3 , w1 = 3 , edge_pad = PAD .ZERO ):
1269+ """
1270+ Apply median filter for the signal.
1271+
1272+ Parameters
1273+ ----------
1274+ signal : af.Array
1275+ - A 2 D arrayfire array representing a signal, or
1276+ - A multi dimensional array representing batch of signals.
1277+
1278+ w0 : optional: int. default: 3.
1279+ - The length of the filter along the first dimension.
1280+
1281+ w1 : optional: int. default: 3.
1282+ - The length of the filter along the second dimension.
1283+
1284+ edge_pad : optional: af.PAD. default: af.PAD.ZERO
1285+ - Flag specifying how the median at the edge should be treated.
1286+
1287+ Returns
1288+ ---------
1289+
1290+ output : af.Array
1291+ - The signal after median filter is applied.
1292+
1293+ """
1294+ output = Array ()
1295+ safe_call (backend .get ().af_medfilt (ct .pointer (output .arr ),
1296+ signal .arr , c_dim_t (w0 ),
1297+ c_dim_t (w1 ), edge_pad .value ))
1298+ return output
1299+
1300+ def medfilt1 (signal , length = 3 , edge_pad = PAD .ZERO ):
1301+ """
1302+ Apply median filter for the signal.
1303+
1304+ Parameters
1305+ ----------
1306+ signal : af.Array
1307+ - A 1 D arrayfire array representing a signal, or
1308+ - A multi dimensional array representing batch of signals.
1309+
1310+ length : optional: int. default: 3.
1311+ - The length of the filter.
1312+
1313+ edge_pad : optional: af.PAD. default: af.PAD.ZERO
1314+ - Flag specifying how the median at the edge should be treated.
1315+
1316+ Returns
1317+ ---------
1318+
1319+ output : af.Array
1320+ - The signal after median filter is applied.
1321+
1322+ """
1323+ output = Array ()
1324+ safe_call (backend .get ().af_medfilt1 (ct .pointer (output .arr ), signal .arr , c_dim_t (length ), edge_pad .value ))
1325+ return output
1326+
1327+ def medfilt2 (signal , w0 = 3 , w1 = 3 , edge_pad = PAD .ZERO ):
1328+ """
1329+ Apply median filter for the signal.
1330+
1331+ Parameters
1332+ ----------
1333+ signal : af.Array
1334+ - A 2 D arrayfire array representing a signal, or
1335+ - A multi dimensional array representing batch of signals.
1336+
1337+ w0 : optional: int. default: 3.
1338+ - The length of the filter along the first dimension.
1339+
1340+ w1 : optional: int. default: 3.
1341+ - The length of the filter along the second dimension.
1342+
1343+ edge_pad : optional: af.PAD. default: af.PAD.ZERO
1344+ - Flag specifying how the median at the edge should be treated.
1345+
1346+ Returns
1347+ ---------
1348+
1349+ output : af.Array
1350+ - The signal after median filter is applied.
1351+
1352+ """
1353+ output = Array ()
1354+ safe_call (backend .get ().af_medfilt2 (ct .pointer (output .arr ),
1355+ signal .arr , c_dim_t (w0 ),
1356+ c_dim_t (w1 ), edge_pad .value ))
1357+ return output
1358+
12681359def set_fft_plan_cache_size (cache_size ):
12691360 """
12701361 Sets plan cache size.
0 commit comments