SIFT  1.1.2
Functions
utils.h File Reference

Miscellaneous utility functions. More...

#include "cxcore.h"
#include <stdio.h>
#include <dirent.h>

Functions

static int pixval8 (IplImage *img, int r, int c)
 A function to get a pixel value from an 8-bit unsigned image. More...
 
static void setpix8 (IplImage *img, int r, int c, uchar val)
 A function to set a pixel value in an 8-bit unsigned image. More...
 
static float pixval32f (IplImage *img, int r, int c)
 A function to get a pixel value from a 32-bit floating-point image. More...
 
static void setpix32f (IplImage *img, int r, int c, float val)
 A function to set a pixel value in a 32-bit floating-point image. More...
 
static double pixval64f (IplImage *img, int r, int c)
 A function to get a pixel value from a 64-bit floating-point image. More...
 
static void setpix64f (IplImage *img, int r, int c, double val)
 A function to set a pixel value in a 64-bit floating-point image. More...
 
void fatal_error (char *format,...)
 Prints an error message and aborts the program. More...
 
char * replace_extension (const char *file, const char *extn)
 Replaces a file's extension, which is assumed to be everything after the last dot ('. More...
 
char * prepend_path (const char *path, const char *file)
 Prepends a path to a filename. More...
 
char * basename (const char *pathname)
 A function that removes the path from a filename. More...
 
void progress (int done)
 Displays progress in the console with a spinning pinwheel. More...
 
void erase_from_stream (FILE *stream, int n)
 Erases a specified number of characters from a stream. More...
 
int array_double (void **array, int n, int size)
 Doubles the size of an array with error checking. More...
 
double dist_sq_2D (CvPoint2D64f p1, CvPoint2D64f p2)
 Calculates the squared distance between two points. More...
 
void draw_x (IplImage *img, CvPoint pt, int r, int w, CvScalar color)
 Draws an x on an image. More...
 
IplImage * stack_imgs (IplImage *img1, IplImage *img2)
 Combines two images by scacking one on top of the other. More...
 
void display_big_img (IplImage *img, char *title)
 Displays an image, making sure it fits on screen. More...
 
void vid_view (IplImage **imgs, int n, char *win_name)
 Allows user to view an array of images as a video. More...
 
int win_closed (char *name)
 Checks if a HighGUI window is still open or not. More...
 

Detailed Description

Miscellaneous utility functions.

Copyright (C) 2006-2010 Rob Hess hess@.nosp@m.eecs.nosp@m..oreg.nosp@m.onst.nosp@m.ate.e.nosp@m.du

Version
1.1.2-20100521

Function Documentation

◆ pixval8()

static int pixval8 ( IplImage *  img,
int  r,
int  c 
)
inlinestatic

A function to get a pixel value from an 8-bit unsigned image.

Parameters
imgan image
rrow
ccolumn
Returns
Returns the value of the pixel at (r, c) in img

◆ setpix8()

static void setpix8 ( IplImage *  img,
int  r,
int  c,
uchar  val 
)
inlinestatic

A function to set a pixel value in an 8-bit unsigned image.

Parameters
imgan image
rrow
ccolumn
valpixel value

◆ pixval32f()

static float pixval32f ( IplImage *  img,
int  r,
int  c 
)
inlinestatic

A function to get a pixel value from a 32-bit floating-point image.

Parameters
imgan image
rrow
ccolumn
Returns
Returns the value of the pixel at (r, c) in img

References feature::c.

◆ setpix32f()

static void setpix32f ( IplImage *  img,
int  r,
int  c,
float  val 
)
inlinestatic

A function to set a pixel value in a 32-bit floating-point image.

Parameters
imgan image
rrow
ccolumn
valpixel value

◆ pixval64f()

static double pixval64f ( IplImage *  img,
int  r,
int  c 
)
inlinestatic

A function to get a pixel value from a 64-bit floating-point image.

Parameters
imgan image
rrow
ccolumn
Returns
Returns the value of the pixel at (r, c) in img

◆ setpix64f()

static void setpix64f ( IplImage *  img,
int  r,
int  c,
double  val 
)
inlinestatic

A function to set a pixel value in a 64-bit floating-point image.

Parameters
imgan image
rrow
ccolumn
valpixel value

References array_double(), basename(), display_big_img(), dist_sq_2D(), draw_x(), erase_from_stream(), fatal_error(), prepend_path(), progress(), replace_extension(), stack_imgs(), vid_view(), and win_closed().

◆ fatal_error()

void fatal_error ( char *  format,
  ... 
)

Prints an error message and aborts the program.

The error message is of the form "Error: ...", where the ... is specified by the format argument

Parameters
formatan error message format string (as with printf(3)).

Referenced by setpix64f().

◆ replace_extension()

char* replace_extension ( const char *  file,
const char *  extn 
)

Replaces a file's extension, which is assumed to be everything after the last dot ('.

') character.

Parameters
filethe name of a file
extna new extension for file; should not include a dot (i.e. "jpg", not ".jpg") unless the new file extension should contain two dots.
Returns
Returns a new string formed as described above. If file does not have an extension, this function simply adds one.

Referenced by setpix64f().

◆ prepend_path()

char* prepend_path ( const char *  path,
const char *  file 
)

Prepends a path to a filename.

Parameters
patha path
filea file name
Returns
Returns a new string containing a full path name consisting of path prepended to file.

Referenced by setpix64f().

◆ basename()

char* basename ( const char *  pathname)

A function that removes the path from a filename.

Similar to the Unix basename command.

Parameters
pathnamea (full) path name
Returns
Returns the basename of pathname.

Referenced by setpix64f().

◆ progress()

void progress ( int  done)

Displays progress in the console with a spinning pinwheel.

Every time this function is called, the state of the pinwheel is incremented. The pinwheel has four states that loop indefinitely: '|', '/', '-', '\'.

Parameters
doneif 0, this function simply increments the state of the pinwheel; otherwise it prints "done"

Referenced by setpix64f().

◆ erase_from_stream()

void erase_from_stream ( FILE *  stream,
int  n 
)

Erases a specified number of characters from a stream.

Parameters
streamthe stream from which to erase characters
nthe number of characters to erase

Referenced by setpix64f().

◆ array_double()

int array_double ( void **  array,
int  n,
int  size 
)

Doubles the size of an array with error checking.

Parameters
arraypointer to an array whose size is to be doubled
nnumber of elements allocated for array
sizesize in bytes of elements in array
Returns
Returns the new number of elements allocated for array. If no memory is available, returns 0 and frees array.

Referenced by setpix64f().

◆ dist_sq_2D()

double dist_sq_2D ( CvPoint2D64f  p1,
CvPoint2D64f  p2 
)

Calculates the squared distance between two points.

Parameters
p1a point
p2another point

Referenced by setpix64f().

◆ draw_x()

void draw_x ( IplImage *  img,
CvPoint  pt,
int  r,
int  w,
CvScalar  color 
)

Draws an x on an image.

Parameters
imgan image
ptthe center point of the x
rthe x's radius
wthe x's line weight
colorthe color of the x

Referenced by setpix64f().

◆ stack_imgs()

IplImage* stack_imgs ( IplImage *  img1,
IplImage *  img2 
)

Combines two images by scacking one on top of the other.

Parameters
img1top image
img2bottom image
Returns
Returns the image resulting from stacking img1 on top if img2

Referenced by setpix64f().

◆ display_big_img()

void display_big_img ( IplImage *  img,
char *  title 
)

Displays an image, making sure it fits on screen.

cvWaitKey() must be called after this function so the event loop is entered and the image is displayed.

Parameters
imgan image, possibly too large to display on-screen
titlethe title of the window in which img is displayed

Referenced by setpix64f().

◆ vid_view()

void vid_view ( IplImage **  imgs,
int  n,
char *  win_name 
)

Allows user to view an array of images as a video.

Keyboard controls are as follows:

  • Space - start and pause playback
  • Page Up - skip forward 10 frames
  • Page Down - jump back 10 frames
  • Right Arrow - skip forward 1 frame
  • Left Arrow - jump back 1 frame
  • Backspace - jump back to beginning
  • Esc - exit playback
  • Closing the window also exits playback
Parameters
imgsan array of images
nnumber of images in imgs
win_namename of window in which images are displayed

Referenced by setpix64f().

◆ win_closed()

int win_closed ( char *  name)

Checks if a HighGUI window is still open or not.

Parameters
namethe name of the window we're checking
Returns
Returns 1 if the window named name has been closed or 0 otherwise

Referenced by setpix64f().