00001 #ifndef __CImageSegmentationIndexFile_h_2005_03_23_15_04_W_AI__
00002 #define __CImageSegmentationIndexFile_h_2005_03_23_15_04_W_AI__
00003
00004 #include "TImageSegmentation.h"
00005
00006 namespace segmentation {
00007
00008
00009 class CImageSegmentationIndexFile
00010 {
00011 public:
00012
00013 static const char segFileExt[2][9];
00014
00015 enum FILE_FORMAT
00016 {
00017 unknown_format = -1,
00018 bsi_format = 0,
00019 martin_seg_format = 1,
00020 format_count = 2
00021 };
00022
00023
00024
00025
00026
00027
00028 static
00029 long Load(const char *filename, long & width, long & height, long * indexArray = NULL);
00030
00031
00032
00033
00034
00035 static
00036 long Load(const char *filename, TImageSegmentation<long> &segmentation);
00037
00038
00039
00040
00041
00042 static
00043 bool Save(const char *filename, const long width, const long height, const long * indexArray, FILE_FORMAT format = bsi_format);
00044
00045
00046
00047
00048
00049 static
00050 bool Save(const char *filename, const TImageSegmentation<long> &segmentation, FILE_FORMAT format = bsi_format);
00051
00052
00053
00054 static
00055 FILE_FORMAT WhichSegmentationIndexFile(const char * filename);
00056
00057
00058 protected:
00059
00060 static
00061 FILE * ReadFileHeader(FILE_FORMAT fileFormat, const char *filename, long & width, long & height);
00062
00063
00064 static
00065 bool ReadFileData(FILE_FORMAT fileFormat, FILE *f, long * indexArray, long width, long height);
00066
00067
00068 static
00069 FILE * ReadBSIFileHeader(const char *filename, long & width, long & height);
00070
00071
00072 static
00073 bool ReadBSIFileData(FILE *f, long * indexArray, long width, long height);
00074
00075
00076 static
00077 FILE * ReadSEGFileHeader(const char *filename, long & width, long & height);
00078
00079
00080 static
00081 bool ReadSEGFileData(FILE *f, long * indexArray, long width, long height);
00082
00083 };
00084
00085 }
00086
00087 #endif
00088