@@ -769,6 +769,48 @@ def sobel_derivatives(image, w_len=3):
769
769
image .arr , ct .c_uint (w_len )))
770
770
return dx ,dy
771
771
772
+ def gaussian_kernel (rows , cols , sigma_r = None , sigma_c = None ):
773
+ """
774
+ Create a gaussian kernel with the given parameters.
775
+
776
+ Parameters
777
+ ----------
778
+ image : af.Array
779
+ - A 2 D arrayfire array representing an image, or
780
+ - A multi dimensional array representing batch of images.
781
+
782
+ rows : int
783
+ - The number of rows in the gaussian kernel.
784
+
785
+ cols : int
786
+ - The number of columns in the gaussian kernel.
787
+
788
+ sigma_r : optional: number. default: None.
789
+ - The sigma value along rows
790
+ - If None, calculated as (0.25 * rows + 0.75)
791
+
792
+ sigma_c : optional: number. default: None.
793
+ - The sigma value along columns
794
+ - If None, calculated as (0.25 * cols + 0.75)
795
+
796
+ Returns
797
+ -------
798
+ out : af.Array
799
+ - A gaussian kernel of size (rows, cols)
800
+ """
801
+ out = Array ()
802
+
803
+ if (sigma_r is None ):
804
+ sigma_r = 0.25 * rows + 0.75
805
+
806
+ if (sigma_c is None ):
807
+ sigma_c = 0.25 * cols + 0.75
808
+
809
+ safe_call (backend .get ().af_gaussian_kernel (ct .pointer (out .arr ),
810
+ ct .c_int (rows ), ct .c_int (cols ),
811
+ ct .c_double (sigma_r ), ct .c_double (sigma_c )))
812
+ return out
813
+
772
814
def sobel_filter (image , w_len = 3 , is_fast = False ):
773
815
"""
774
816
Apply sobel filter to the image.
0 commit comments