Main Page | Alphabetical List | Class List | File List | Class Members | File Members

Segmentation.cpp File Reference

File where input, segmentation and output is performed. More...

#include <math.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <sys\types.h>
#include "Segmentation.h"
#include "OrderedLists.h"
#include "DateTime.h"

Defines

#define DECIMAL_POSITIONS   4
#define ERROR_MESSAGE_LENGTH   80
#define EXPECTED_PARENTS_NUMBER   1000
#define LINE_WIDTH   120
#define MAX_DIST   1.0
#define MAX_RESULT_RGB   (255.0 * sqrt(3));
#define MIN_NORM   1.0
#define NAME_LENGTH   80
#define PI   3.14159265358979323846
#define SHORT_AUXILIARY_STRING_LENGTH   20
#define WORD_WIDTH   20

Functions

void allocateFilesList (char **&filesList)
int changeBase (int iNumber, int *iBaseNumber, int iBase)
int changeCartesianVermis (int c, int r, int cols)
void changeRGBToHSV (double r, double g, double b, double &h, double &s, double &v)
void changeVermisCartesian (int vermis, int cols, int *c, int *r)
int compare_w (const void *, const void *)
void copyImageBW (PixelPlane final, PixelPlane initial, int rows, int cols)
 Copies the pixels in initial PixelPlane into final.

void copyImageColour (PixelPlane finalr, PixelPlane finalg, PixelPlane finalb, PixelPlane initialr, PixelPlane initialg, PixelPlane initialb, int rows, int cols)
void displayInstructionsMessage (void)
void FatalError (char const *message)
pixel_type findminmaxw (edge_type *, int)
int FindSet (int, node_type *)
void freeFilesList (char **filesList)
 Frees memory allocated by allocateFilesList.

void generateFileNames (char *filesList[], SegmentationParameters &parms)
 Generates the names of the output files.

void getArgumentsFromUser (int argc, char *argv[], SegmentationParameters &parms, char *filesList[])
 Stores the program arguments in their respective variables.

void initializeOptionsViaDefine (SegmentationOptions &segmentation, OutputOptions &output)
 Initialize all options needed via data supplied through #DEFINES.

int Link (int, int, node_type *, float)
void logbucketsort (edge_type *, edge_type *, int, int)
double mesureColourDistance (double r1, double g1, double b1, double r0, double g0, double b0)
double mesureDistance (PixelType *pixelA, PixelType *pixelB, ImageType type, unsigned nPlanes, PixelMetric metric)
 Returns the selected metric distance between 2 pixels.

double mesureHueDistance (double r1, double g1, double b1, double r2, double g2, double b2)
double mesureToneDistance (double r1, double g1, double b1, double r2, double g2, double b2)
double MInt (int, int, node_type *, SegmentationParameters const &parms)
double norm3D (double x, double y, double z)
double obtainHueFromRGB (double r, double g, double b)
double productScalar (double r1, double g1, double b1, double r0, double g0, double b0)
int roundPositiveDoubleToNearest (double number)
int searchNeighborSpot (int iInitialPixel, node_type *F, int cols, int rows)
size_t segmentBWImage (SimplePixelImage &originalImage, SegmentationParameters const &parms, double *elapsedtime)
size_t segmentRGBImage (SimplePixelImage &originalImage, SegmentationOptions const &segmentation, double *elapsedtime, int *(**iSpotPixels), SpotStatistics *(*sSegmentationStatistics))
size_t segmentSimplePixelImage (SimplePixelImage const &inputImage, int *(**iSpotPixels), SegmentationOptions const &segmentation, SpotStatistics *(*sSegmentationStatistics), FilesOptions const &files)
 Segments a Simple Pixel Image according to the SegmentationOptions.

double sqr (double a)
float weightConnection ()
in void writeSpotStatistics (char *spot_statistics_file, SpotStatistics *sSegmentationStatistics, size_t sizeTotalSegments)
 Writes into file the statistics for each segment.


Detailed Description

File where input, segmentation and output is performed.

Warning:
This file should only be consulted, when the information provided in the headers does not suffice to clear up any question.

Function Documentation

void allocateFilesList char **&  filesList  ) 
 

Allocates memory for files List and initializes them with the '\0' character

void copyImageColour PixelPlane  finalr,
PixelPlane  finalg,
PixelPlane  finalb,
PixelPlane  initialr,
PixelPlane  initialg,
PixelPlane  initialb,
int  rows,
int  cols
 

Copies each PixelPlane into the corresponding one. that is: copies initialr into finalr, initialg into finalg, and so on.

void generateFileNames char *  filesList[],
SegmentationParameters parms
 

Generates the names of the output files.

From the full file name (path+name) -stored in SOURCE_FILE position of filesList- this function generates the rest of files names and stores them in filesList.
These generated file names are the ones enumerated in _FileName.
filesList properties are detailed in _FilesOptions.list

Example:
Given filesList[SOURCE_FILE] , a pointer to the string "c:\anypath\anyname.ppm" this function generates the following strings of file names:
  • filesList[IMAGE_NAME] pointer to string "anyname.ppm"
  • filesList[MEDIAN_FILE] pointer to string "c:\anypath\anyname_med_n.ppm" where n is the size of the median window, it is set to 3 by default but modifiable via define #WINDOW_WIDTH
  • filesList[SEGMENTED_FILE] pointer to string "c:\anypath\anyname_segm_Kint_Kdec.ppm" . Kint stands for the integer part of K , and Kdec for its decimal part with as many digits as fixed by DECIMAL_POSITIONS. That is, if $ K = 2.327635 $ and DECIMAL_POSITIONS = 4 the output is "c:\anypath\anyname_segm_2_3276.ppm"
  • filesList[SPOT_STATISTICS_FILE] pointer to string "c:\anypath\anyname_stat_Kint_Kdec.ppm" . Where Kint and Kdec meaning is explained in the item above.

void getArgumentsFromUser int  argc,
char *  argv[],
SegmentationParameters parms,
char *  filesList[]
 

Stores the program arguments in their respective variables.

These arguments must be introduced in the following order:

Obligatory

  • File Name: saved in position SOURCE_FILE of the string array filesList

Optional

  1. K
  2. minarea
  3. maxarea

void initializeOptionsViaDefine SegmentationOptions segmentation,
OutputOptions output
 

Initialize all options needed via data supplied through #DEFINES.

size_t segmentSimplePixelImage SimplePixelImage const &  inputImage,
int ***  iSpotPixels,
SegmentationOptions const &  options,
SpotStatistics **  sSegmentationStatistics,
FilesOptions const &  files
 

Segments a Simple Pixel Image according to the SegmentationOptions.

Parameters:
[in] inputImage The image to segment, stored in a _SimplePixelImage struct. It is advisable to begin with the function readPortableMapToSimplePixelImage to get easily started.
[out] iSpotPixels Array of the spots, where each spot is an array of the positions of its pixels. For instance: iSpotPixels[2][10] Gives the position of the 10th pixel of the 2nd spot.
[in] options By means of this _SegmentationOptions structure are passed all the option values. needed to carry out segmentation.
[in] files This _FilesOptions structure is used to pass
[out] sSegmentationStatistics It's an array of the type SpotStatistics. The position in the array represents the number of spot.
See also:
SimplePixelImage.h to know about all the image data types and functions

void writeSpotStatistics char *  spot_statistics_file,
SpotStatistics sSegmentationStatistics,
size_t  sizeTotalSegments
 

Writes into file the statistics for each segment.

Parameters:
spot_statistics_file Pointer to the file name.
sSegmentationStatistics The array where the statistics of each spot is held.
sizeTotalSegments The total number of segments stored in sSegmentationStatistics
See also:
FilesOptions.list


Generated on Wed Jul 14 17:25:04 2004 for Segmentation by doxygen 1.3.7