sift.c File Reference

Scale Invariant Feature Transform (SIFT) - Definition. More...

#include "sift.h"
#include "imop.h"
#include "mathop.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>

Defines

#define VL_SIFT_BILINEAR_ORIENTATIONS   1
 Use bilinear interp. to compute orientations.
#define EXPN_SZ   256
#define EXPN_MAX   25.0

Functions

VL_INLINE double fast_expn (double x)
 Fast $exp(-x)$ approximation.
VL_INLINE void fast_expn_init ()
 Initialize tables for fast_expn.
static void copy_and_upsample_rows (vl_sift_pix *dst, vl_sift_pix const *src, int width, int height)
 Copy imge, upsample rows and take transpose.
static void copy_and_downsample (vl_sift_pix *dst, vl_sift_pix const *src, int width, int height, int d)
 Copy and downsample an image.
VlSiftFiltvl_sift_new (int width, int height, int O, int S, int o_min)
 Create a new SIFT filter.
void vl_sift_delete (VlSiftFilt *f)
 Delete SIFT filter.
int vl_sift_process_first_octave (VlSiftFilt *f, vl_sift_pix const *im)
 Start processing a new image.
int vl_sift_process_next_octave (VlSiftFilt *f)
 Process next octave.
void vl_sift_detect (VlSiftFilt *f)
 Detect keypoints.
static void update_gradient (VlSiftFilt *f)
 Update gradients to current GSS octave.
int vl_sift_calc_keypoint_orientations (VlSiftFilt *f, double angles[4], VlSiftKeypoint const *k)
 Calculate the keypoint orientation(s).
VL_INLINE vl_sift_pix normalize_histogram (vl_sift_pix *begin, vl_sift_pix *end)
 Normalizes in norm L_2 a descriptor.
void vl_sift_calc_keypoint_descriptor (VlSiftFilt *f, vl_sift_pix *descr, VlSiftKeypoint const *k, double angle0)
 Compute the descriptor of a keypoint.
void vl_sift_keypoint_init (VlSiftFilt const *f, VlSiftKeypoint *k, double x, double y, double sigma)
 Initialize a keypoint from its position and scale.

Variables

double expn_tab [EXPN_SZ]


Detailed Description

For internal use only.

Author:
Andrea Vedaldi


Define Documentation

#define EXPN_MAX   25.0

fast_expn table max

For internal use only.

#define EXPN_SZ   256

fast_expn table size

For internal use only.

#define VL_SIFT_BILINEAR_ORIENTATIONS   1

For internal use only.


Function Documentation

static void copy_and_downsample ( vl_sift_pix dst,
vl_sift_pix const *  src,
int  width,
int  height,
int  d 
) [static]

For internal use only.

Parameters:
dst output imgae buffer.
src input image buffer.
width input image width.
height input image height.
d octaves (non negative).
The function downsamples the image d times, reducing it to 1/2^d of its original size. The parameters width and height are the size of the input image. The destination image dst is assumed to be floor(width/2^d) pixels wide and floor(height/2^d) pixels high.

static void copy_and_upsample_rows ( vl_sift_pix dst,
vl_sift_pix const *  src,
int  width,
int  height 
) [static]

For internal use only.

Parameters:
dst output imgage buffer.
src input image buffer.
width input image width.
height input image height.
The output image has dimensions height by 2 width (so the the destination buffer must be at least as big as two times the input buffer).

Upsampling is performed by linear interpolation.

VL_INLINE double fast_expn ( double  x  ) 

For internal use only.

Parameters:
x argument.
The argument must be in the range [0, EXPN_MAX] .

Returns:
approximation of $exp(-x)$.

VL_INLINE void fast_expn_init (  ) 

For internal use only.

VL_INLINE vl_sift_pix normalize_histogram ( vl_sift_pix begin,
vl_sift_pix end 
)

For internal use only.

Parameters:
begin begin of histogram.
end end of histogram.

static void update_gradient ( VlSiftFilt f  )  [static]

For internal use only.

Parameters:
f SIFT filter.
The function makes sure that the gradient buffer is up-to-date with the current GSS data.

Remarks:
The minimum octave size is 2x2xS.

void vl_sift_calc_keypoint_descriptor ( VlSiftFilt f,
vl_sift_pix descr,
VlSiftKeypoint const *  k,
double  angle0 
)

Parameters:
f SIFT filter.
descr SIFT descriptor (output)
k keypoint.
angle0 keypoint direction.
The function computes the SIFT descriptor of the keypoint k of orientation angle0. The function fills the buffer descr which must be large enough to hold the descriptor.

The function assumes that the keypoint is on the current octave. If not, it does not do anything.

int vl_sift_calc_keypoint_orientations ( VlSiftFilt f,
double  angles[4],
VlSiftKeypoint const *  k 
)

Parameters:
f SIFT filter.
angles orientations (output).
k keypoint.
The function computes the orientation(s) of the keypoint k. The function returns the number of orientations found (up to four). The orientations themselves are written to the vector angles.

Remarks:
The function requires the keypoint octave k->o to be equal to the filter current octave vl_sift_get_octave. If this is not the case, the function returns zero orientations.

The function requries the keypoint scale level k->s to be in the range s_min+1 and s_max-2 (where usually s_min=0 and s_max=S+2). If this is not the case, the function returns zero orientations.

Returns:
number of orientations found.

void vl_sift_delete ( VlSiftFilt f  ) 

Parameters:
f SIFT filter to delete.
The function frees the resources allocated by vl_sift_new().

void vl_sift_detect ( VlSiftFilt f  ) 

The function detect keypoints in the current octave filling the internal keypoint buffer. Keypoints can be retrieved by vl_sift_get_keypoints().

Parameters:
f SIFT filter.

Index GSS

For internal use only.

Index matrix A

void vl_sift_keypoint_init ( VlSiftFilt const *  f,
VlSiftKeypoint k,
double  x,
double  y,
double  sigma 
)

Parameters:
f SIFT filter.
k SIFT keypoint (output).
x x coordinate of the center.
y y coordinate of the center.
sigma scale.
The function initializes the structure k from the location x and y and scale sigma of the keypoint.

VlSiftFilt* vl_sift_new ( int  width,
int  height,
int  O,
int  S,
int  o_min 
)

Parameters:
width image width.
height image height.
O number of octaves.
S number of levels per octave.
o_min first octave index.
The function allocates and returns a new SIFT filter for the specified image and scale space geomtery.

Setting O to a negative value sets the number of octaves to the maximum possible value depending on the size of the image.

Returns:
the new SIFT filter.
See also:
vl_sift_delete().

int vl_sift_process_first_octave ( VlSiftFilt f,
vl_sift_pix const *  im 
)

Parameters:
f SIFT filter.
im image data.
The function starts processing a new image by computing its Gaussian scale spadce at the lower octave. It also empties the internal keypoint buffer.

Returns:
error code. The function returns VL_ERR_EOF if there are no more octaves to process.
See also:
vl_sift_process_next_octave().

int vl_sift_process_next_octave ( VlSiftFilt f  ) 

Parameters:
f SIFT filter.
The function computes the next octave of the Gaussian scale space. Notice that this clears the record of any feature detected in the previous octave.

Returns:
error code. The function returns the error VL_ERR_EOF when there are no more ocvatves to process.
See also:
vl_sift_process_first_octave().


Variable Documentation

double expn_tab[EXPN_SZ]

fast_expn table

For internal use only.


Generated on Mon Jan 21 17:43:33 2008 for vlfeat by  doxygen 1.5.4