00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
#ifndef SEGMENTATION_H
00017
#define SEGMENTATION_H
00018
00019
#include "SimplePixelImage.h"
00020
#include "MedianFilter.h"
00021
#include "AllocMem.h"
00022
00023
00024
00025
00026
00027
00031
00032
00033
00034
00035
#define PERFORM_MEDIAN_FILTER false
00036
#define FRAME_TYPE FRAME_UNCHANGED
00037
00038
00039
00040
00041
#define K_DEFAULT 0.5
00042
#define MIN_AREA_DEFAULT 100.0
00043
#define MAX_AREA_DEFAULT 5000.0
00044
#define SEGMENTATION_METRIC METRIC_TONE
00045
00046
00047
00051
00052
00053
00054
00055
#define EXTREME_SPOTS_SHADING false
00056
#define EXTREME_SPOTS_DISOLVING false
00057
#define SPOTS_MARKING false
00058
00059 #define PRINT_FILE_STATISTICS true
00060
00061
00062
00063
00064
00065
00066 #define PRINT_FILE_MEDIAN true
00067
00068
00069
00070
00071 #define PRINT_FILE_SEGMENTED true
00072
00073
00074
00075
00076
00077
00078
00079 #define DECIMAL_POSITIONS 4
00080
00081
00082
00083
00084
00085
00086
00087
00088
00090
00091
00092
00093
00094
00095
00096
00103 typedef enum _PixelMetric
00104 {
00105
METRIC_EUCLIDEAN,
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
METRIC_TONE,
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
METRIC_HUE,
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
METRICS_NUMBER
00154 }
00155
PixelMetric;
00156
00157
00158
00159
00161 typedef struct _SegmentationParameters {
00162 double K;
00163
00164
00165
00166
00167
00168 double minarea;
00169
00170
00171
00172
00173
00174
00175
00176
00177 double maxarea;
00178
00179
00180
00181
00182
00183 PixelMetric segmentationMetric;
00184
00185
00186
00187
00188
00189 }
SegmentationParameters;
00190
00191
00192
00193
00194
00205 typedef enum _FileName
00206 {
00207
SOURCE_FILE,
00208
00209
00210
IMAGE_NAME,
00211
00212
MEDIAN_FILE,
00213
00214
SEGMENTED_FILE,
00215
00216
SPOT_STATISTICS_FILE,
00217
00218
00219
00220
00221
00222
00223
FILES_NUMBER
00224
00225
00226
00227 }
00228
FileName;
00229
00248 typedef struct _SegmentationOptions
00249 {
00251
00252 bool shouldPerformMedianFilter;
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 FrameProcessing
frameMedian;
00263
00264
00265
00266
00267
00268
00270
00271 SegmentationParameters parameters;
00272
00273
00275
00276 bool shouldDisolveExtremeSpots;
00277
00278
00279
00280
00281
00282
00283 size_t
expectedParents;
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 }
00295
SegmentationOptions;
00296
00299 typedef struct _FilesOptions
00300 {
00301 bool shouldPrint[
FILES_NUMBER ];
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312 char **
list;
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 }
00326
FilesOptions;
00327
00335 typedef struct _OutputOptions
00336 {
00337
FilesOptions files;
00338 bool shouldShadeExtremeSpots;
00339
00340
00341
00342
00343
00344
00345
00346
00347 bool shouldMarkSpots;
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 }
00360
OutputOptions;
00361
00363 typedef struct _PointDouble
00364 {
00365 double dRow;
00366 double dCol;
00367 }
PointDouble;
00368
00370 typedef struct _SpotStatistics
00371 {
00372 size_t
sizeSpotSize;
00373 double ucAverageRed;
00374 double ucAverageGreen;
00375 double ucAverageBlue;
00376 PointDouble massCentre;
00377 }
00378
SpotStatistics;
00379
00382
void allocateFilesList (
char**& filesList );
00384
void freeFilesList (
char** fileslist);
00385
00388 #define KEEP_ORIGINAL_PATH true
00389
00390
00392 #define OUTPUT_PATH "" //Path for output images (i.e. median.ppm, segm.ppm, and so forth)
00393
00394
00395
00396
00397
00398
00400
void copyImageBW (PixelPlane
final, PixelPlane initial,
int rows,
int cols);
00403
void copyImageColour (PixelPlane finalr, PixelPlane finalg, PixelPlane finalb, PixelPlane initialr, PixelPlane initialg, PixelPlane initialb,
int rows,
int cols);
00404
00405
00406
00413
void initializeOptionsViaDefine (
SegmentationOptions &segmentation,
OutputOptions &output);
00414
00427
void getArgumentsFromUser (
int argc,
char *argv[],
SegmentationParameters &parms,
char *filesList[]);
00428
00429
00454
void generateFileNames (
char *filesList[],
SegmentationParameters &parms);
00455
00456
00457
00458
00459
00460
00477
00478 size_t
segmentSimplePixelImage(
SimplePixelImage const &inputImage,
int *(**iSpotPixels),
00479
SegmentationOptions const &options,
00480
SpotStatistics *(*sSegmentationStatistics),
00481
FilesOptions const &files);
00482
00483
#endif //SEGMENTATION_H