sift: 2D image alignment

class silx.image.sift.SiftPlan(shape=None, dtype=None, devicetype='ALL', template=None, profile=False, device=None, PIX_PER_KP=None, max_workgroup_size=None, context=None, init_sigma=None)

This class implements a way to calculate SIFT keypoints.

How to calculate a set of SIFT keypoint on an image:

siftp = sift.SiftPlan(img.shape,img.dtype,devicetype="GPU")
kp = siftp.keypoints(img)

kp is a nx132 array. the second dimension is composed of x,y, scale and angle as well as 128 floats describing the keypoint

This SIFT algorithm is patented: U.S. Patent 6,711,293: “Method and apparatus for identifying scale invariant features in an image and use of same for locating an object in an image”,

count_kp(output)

Print the number of keypoint per octave

keypoints(image)

Calculates the keypoints of the image

Parameters:image – ndimage of 2D (or 3D if RGB)
Returns:vector of keypoint (1D numpy array)
log_profile()

If we are in debugging mode, prints out all timing for every single OpenCL call

reset_timer()

Resets the profiling timers

class silx.image.sift.MatchPlan(size=16384, devicetype='ALL', profile=False, device=None, max_workgroup_size=None, roi=None, context=None)

Plan to compare sets of SIFT keypoint and find common ones.

siftp = sift.MatchPlan(devicetype="ALL")
commonkp = siftp.match(kp1,kp2)

where kp1, kp2 is a n x 132 array. the second dimension is composed of x,y, scale and angle as well as 128 floats describing the keypoint. commonkp is mx2 array of matching keypoints

match(nkp1, nkp2, raw_results=False)

Calculate the matching of 2 keypoint list

Parameters:
  • nkp1 – numpy 1D recarray of keypoints or equivalent GPU buffer
  • nkp2 – numpy 1D recarray of keypoints or equivalent GPU buffer
  • raw_results – if true return the 2D array of indexes of matching keypoints (not the actual keypoints)

TODO: implement the ROI ...

reset_timer()

Resets the profiling timers

set_roi(roi)

Defines the region of interest

Parameters:roi – region of interest as 2D numpy array with non zero where valid pixels are
unset_roi()

Unset the region of interest

class silx.image.sift.LinearAlign(image, devicetype='CPU', profile=False, device=None, max_workgroup_size=None, ROI=None, extra=0, context=None, init_sigma=None)

Align images on a reference image based on an afine transformation (bi-linear + offset)

align(img, shift_only=False, return_all=False, double_check=False, relative=False, orsa=False)

Align image on reference image

Parameters:
  • img – numpy array containing the image to align to reference
  • return_all – return in addition ot the image, keypoints, matching keypoints, and transformations as a dict
  • reltive – update reference keypoints with those from current image to perform relative alignment
Returns:

aligned image or all informations

log_profile()

If we are in debugging mode, prints out all timing for every single OpenCL call

Previous topic

shapes: 2D shapes drawing

Next topic

silx.math:

This Page