@@ -126,6 +126,7 @@ def orb(image, threshold=20.0, max_features=400, scale = 1.5, num_levels = 4, bl
126126 Returns
127127 ---------
128128 (features, descriptor) : tuple of (af.Features(), af.Array)
129+ - descriptor is an af.Array of size N x 8
129130
130131 """
131132 feat = Features ()
@@ -303,3 +304,137 @@ def dog(image, radius1, radius2):
303304 safe_call (backend .get ().af_dog (ct .pointer (out .arr ),
304305 image .arr , radius1 , radius2 ))
305306 return out
307+
308+ def sift (image , num_layers = 3 , contrast_threshold = 0.04 , edge_threshold = 10.0 , initial_sigma = 1.6 ,
309+ double_input = True , intensity_scale = 0.00390625 , feature_ratio = 0.05 ):
310+ """
311+ SIFT feature detector and descriptor.
312+
313+ Parameters
314+ ----------
315+ image : af.Array
316+ A 2D array representing an image
317+
318+ num_layers : optional: integer. Default: 3
319+ Number of layers per octave. The number of octaves is calculated internally.
320+
321+ contrast_threshold : optional: float. Default: 0.04
322+ Threshold used to filter out features that have low contrast.
323+
324+ edge_threshold : optional: float. Default: 10.0
325+ Threshold used to filter out features that are too edge-like.
326+
327+ initial_sigma : optional: float. Default: 1.6
328+ The sigma value used to filter the input image at the first octave.
329+
330+ double_input : optional: bool. Default: True
331+ If True, the input image will be scaled to double the size for the first octave.
332+
333+ intensity_scale : optional: float. Default: 1.0/255
334+ The inverse of the difference between maximum and minimum intensity values.
335+
336+ feature_ratio : optional: float. Default: 0.05
337+ Specifies the maximum number of features to detect as a ratio of image pixels.
338+
339+ Returns
340+ --------
341+ (features, descriptor) : tuple of (af.Features(), af.Array)
342+ - descriptor is an af.Array of size N x 128
343+
344+ """
345+
346+ feat = Features ()
347+ desc = Array ()
348+ safe_call (af_sift (ct .pointer (feat ), ct .pointer (desc ),
349+ image .arr , num_layers , contrast_threshold , edge_threshold ,
350+ initial_sigma , double_input , intensity_scale , feature_ratio ))
351+
352+ return (feat , desc )
353+
354+ def gloh (image , num_layers = 3 , contrast_threshold = 0.04 , edge_threshold = 10.0 , initial_sigma = 1.6 ,
355+ double_input = True , intensity_scale = 0.00390625 , feature_ratio = 0.05 ):
356+ """
357+ GLOH feature detector and descriptor.
358+
359+ Parameters
360+ ----------
361+ image : af.Array
362+ A 2D array representing an image
363+
364+ num_layers : optional: integer. Default: 3
365+ Number of layers per octave. The number of octaves is calculated internally.
366+
367+ contrast_threshold : optional: float. Default: 0.04
368+ Threshold used to filter out features that have low contrast.
369+
370+ edge_threshold : optional: float. Default: 10.0
371+ Threshold used to filter out features that are too edge-like.
372+
373+ initial_sigma : optional: float. Default: 1.6
374+ The sigma value used to filter the input image at the first octave.
375+
376+ double_input : optional: bool. Default: True
377+ If True, the input image will be scaled to double the size for the first octave.
378+
379+ intensity_scale : optional: float. Default: 1.0/255
380+ The inverse of the difference between maximum and minimum intensity values.
381+
382+ feature_ratio : optional: float. Default: 0.05
383+ Specifies the maximum number of features to detect as a ratio of image pixels.
384+
385+ Returns
386+ --------
387+ (features, descriptor) : tuple of (af.Features(), af.Array)
388+ - descriptor is an af.Array of size N x 272
389+
390+ """
391+
392+ feat = Features ()
393+ desc = Array ()
394+ safe_call (af_gloh (ct .pointer (feat ), ct .pointer (desc ),
395+ image .arr , num_layers , contrast_threshold , edge_threshold ,
396+ initial_sigma , double_input , intensity_scale , feature_ratio ))
397+
398+ return (feat , desc )
399+
400+ def homography (x_src , y_src , x_dst , y_dst , htype = HOMOGRAPHY .RANSAC ,
401+ ransac_threshold = 3.0 , iters = 1000 , out_type = Dtype .f32 ):
402+ """
403+ Homography estimation
404+
405+ Parameters
406+ ----------
407+ x_src : af.Array
408+ A list of x co-ordinates of the source points.
409+
410+ y_src : af.Array
411+ A list of y co-ordinates of the source points.
412+
413+ x_dst : af.Array
414+ A list of x co-ordinates of the destination points.
415+
416+ y_dst : af.Array
417+ A list of y co-ordinates of the destination points.
418+
419+ htype : optional: af.HOMOGRAPHY. Default: HOMOGRAPHY.RANSAC
420+ htype can be one of
421+ - HOMOGRAPHY.RANSAC: RANdom SAmple Consensus will be used to evaluate quality.
422+ - HOMOGRAPHY.LMEDS : Least MEDian of Squares is used to evaluate quality.
423+
424+ ransac_threshold : optional: scalar. Default: 3.0
425+ If `htype` is HOMOGRAPHY.RANSAC, it specifies the L2-distance threshold for inliers.
426+
427+ out_type : optional. af.Dtype. Default: Dtype.f32.
428+ Specifies the output data type.
429+
430+ Returns
431+ -------
432+ (H, inliers) : A tuple of (af.Array, integer)
433+ """
434+
435+ H = Array ()
436+ inliers = ct .c_int (0 )
437+ safe_call (backend .get ().af_homography (ct .pointer (H ), ct .pointer (inliers ),
438+ x_src .arr , y_src .arr , x_dst .arr , y_dst .arr ,
439+ htype .value , ransac_threshold , iters , out_type .value ))
440+ return (H , inliers )
0 commit comments