Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

ellipse.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include "include/ellipse.h"

Functions

void ellipseInit (ELLIPSE *ell)
void ellipseEmpty (ELLIPSE *ell)
void ellipseInfo (ELLIPSE *ell)
int ellipseAllocate (ELLIPSE *ell, int imgDim)
int ellipseSetFromParams (ELLIPSE *ell, int imgDim, float *semis, float *cent, float incli, float val)
int ellipseReadEllipse (FILE *fp, ELLIPSE *ell)
int ellipseSaveEllipse (ELLIPSE *ell, FILE *fp)
float ellipseGetMajor (ELLIPSE *ell)
float ellipseGetMinor (ELLIPSE *ell)
float ellipseGetCenterX (ELLIPSE *ell)
float ellipseGetCenterY (ELLIPSE *ell)
float ellipseGetInclination (ELLIPSE *ell)
int ellipseGetImgSize (ELLIPSE *ell)
int ellipseGetValue (ELLIPSE *ell)
int ** ellipseGetArray (ELLIPSE *ell)
int ellipseIsInside (ELLIPSE *ell, int row, int col)

Function Documentation

int ellipseAllocate ELLIPSE ell,
int  imgDim
 

Allocates memory for ELLIPSE data. Normally used only in SET-functions. *ell is initialized && imgDim is positive memory is allocated for ELLIPSE structure.

Parameters:
ELLIPSE *ell pointer to ellipse for which the allocation is done.
int imgDim size of the image plane on which the ellipse is to be done.
Returns:
0 if ok.

void ellipseEmpty ELLIPSE ell  ) 
 

Frees the memory allocated for ellipse. All data is cleared. . ellipse is emptied.

Parameters:
ELLIPSE ell pointer to ellipse to be emptied.

int** ellipseGetArray ELLIPSE ell  ) 
 

Returns the ellipse array of the given ellipse. Ellipse array contains n x n items, single item is one if it is inside the ellipse and zero otherwise. Coordinates on a two dimensional plane are numbered from upper left corner. ell is initialized. .

Parameters:
ELLIPSE *ell pointer to ellipse.
Returns:
the ellipse array of the given ellipse.

float ellipseGetCenterX ELLIPSE ell  ) 
 

Returns the center x-coordinate of the ellipse. ell is initialized. .

Parameters:
ELLIPSE *ell pointer to ellipse.
Returns:
the center x-coordinate of the given ellipse, some negative value if ERROR.

float ellipseGetCenterY ELLIPSE ell  ) 
 

Returns the center y-coordinate of the ellipse. ell is initialized. .

Parameters:
ELLIPSE *ell pointer to ellipse.
Returns:
the center y-coordinate of the given ellipse, some negative value if ERROR.

int ellipseGetImgSize ELLIPSE ell  ) 
 

Returns the size of the image plane on which the ellipse is drawn. ell is initialized. .

Parameters:
ELLIPSE *ell pointer to ellipse.
Returns:
the size of the image plane of the given ellipse, some negative value if ERROR.

float ellipseGetInclination ELLIPSE ell  ) 
 

Returns the inclination of the ellipse. ell is initialized. .

Parameters:
ELLIPSE *ell pointer to ellipse.
Returns:
the inclination of the given ellipse, some negative value if ERROR.

float ellipseGetMajor ELLIPSE ell  ) 
 

Returns the major semiaxe of the ellipse. ell is initialized. .

Parameters:
ELLIPSE *ell pointer to ellipse.
Returns:
the major semiaxe of the given ellipse, some negative value if ERROR.

float ellipseGetMinor ELLIPSE ell  ) 
 

Returns the minor semiaxe of the ellipse. ell is initialized. .

Parameters:
ELLIPSE *ell pointer to ellipse.
Returns:
the minor semiaxe of the given ellipse, some negative value if ERROR.

int ellipseGetValue ELLIPSE ell  ) 
 

Returns the value of the pixels inside the ellipse.

Parameters:
ELLIPSE *ell pointer to ellipse.
Returns:
the value of the pixels inside the ellipse.

void ellipseInfo ELLIPSE ell  ) 
 

Prints the information of the ellipse to the screen.

Parameters:
ELLIPSE *ell pointer to ellipse to be printed.

void ellipseInit ELLIPSE ell  ) 
 

Initializes ELLIPSE datatype for use. To be used before any use of ELLIPSE type variables. . ellipse is initialized.

Parameters:
ELLIPSE *ell pointer to ellipse to be initialized.

int ellipseIsInside ELLIPSE ell,
int  row,
int  col
 

Tests whether the given pixel is inside the given ellipse or not. ell is initialized && 0<=row<=imgDim-1 && 0<=col<=imgDim-1 .

Parameters:
ELLIPSE *ell ellipse on which the testing is to be done.
int row row coordinate of a pixel.
int col column coordinate of a pixel.
Returns:
one if the given pixel is inside the given ellipse zero otherwise, some negative value if ERROR.

int ellipseReadEllipse FILE *  fp,
ELLIPSE ell
 

Reads one ellipse from the given file to the given ELLIPSE structure. A coordinate file contains the parameters of the ellipses in one line in the following order: Coordinate 1: v the additive intensity value of the ellipse Coordinate 2: a the length of the horizontal semi-axis of the ellipse Coordinate 3: b the length of the vertical semi-axis of the ellipse Coordinate 4: x the x-coordinate of the center of the ellipse Coordinate 5: y the y-coordinate of the center of the ellipse Coordinate 6: p the angle (in degrees) between the horizontal semi-axis of the ellipse and the x-axis of the image Coordinate 7: d the image dimension *fp is a pointer to open file containing ellipse(s) in correct format. *ell is initialized an ellipse is read from the file fname.

Parameters:
FILE *fp a pointer to open file containing ellipse(s).
ELLIPSE *ell pointer to ELLIPSE structure where the read ellipse is to be set.
Returns:
0 if ok 1 if there were no more ellipses.

int ellipseSaveEllipse ELLIPSE ell,
FILE *  fp
 

Adds the given ellipse to the file. *ell is initialized. ellipse is saved in the file called fname.

Parameters:
ELLIPSE *ell pointer to the ellipse to be saved.
FILE *fp open file for saving.
Returns:
0 if OK.

int ellipseSetFromParams ELLIPSE ell,
int  imgDim,
float *  semis,
float *  cent,
float  incli,
float  val
 

Sets the ellipse according to given coordinates and image dimension. Notice that the origin is in the middle. *ell is initialized. imgDim is positive. semis[i] are positive. -imgDim/2<=cent[i]<=imgDim/2. ellipse is set.

Parameters:
ELLIPSE *ell pointer to ellipse for which the setting is to be done.
int imgDim size of the image plane.
float *semis major and minor semiaxis of the ellipse.
float *cent center of the ellipse.
float incli inclination of the ellipse.
float value value inside the ellipse.
Returns:
0 if ok.


Generated on Tue Nov 29 15:16:09 2005 by  doxygen 1.4.1