00001
00002
00003
00004
00005 #include "volume_data.h"
00006
00007 #include "grid_queue.h"
00008 #include "grid_queue2.h"
00009
00010
00011
00012 #include "priority_queue.h"
00013
00014
00015 #ifndef SKELETON_MAKER_VOLUME_H
00016 #define SKELETON_MAKER_VOLUME_H
00017
00018 #define MAX_SHEETS 100000
00019 #define MAX_QUEUELEN 5000000
00020 #define MAX_ERODE 1000
00021
00022 using namespace std;
00023
00024 namespace wustl_mm {
00025 namespace SkeletonMaker {
00026
00027 const int neighbor6[6][3]={{0,0,1},{0,0,-1},{0,1,0},{0,-1,0},{1,0,0},{-1,0,0}} ;
00028 const int neighbor4[4][2]={{0,1},{0,-1},{1,0},{-1,0}} ;
00029 const int neighbor64[6][4][3] = {
00030 {{0,1,0},{0,-1,0},{1,0,0},{-1,0,0}},
00031 {{0,1,0},{0,-1,0},{1,0,0},{-1,0,0}},
00032 {{0,0,1},{0,0,-1},{1,0,0},{-1,0,0}},
00033 {{0,0,1},{0,0,-1},{1,0,0},{-1,0,0}},
00034 {{0,0,1},{0,0,-1},{0,1,0},{0,-1,0}},
00035 {{0,0,1},{0,0,-1},{0,1,0},{0,-1,0}}} ;
00036
00037 const int sheetNeighbor[12][4][3] = {
00038 {{0,-1,-1},{0,-1,0},{0,0,-1},{0,0,0}},
00039 {{0,-1,0},{0,-1,1},{0,0,0},{0,0,1}},
00040 {{0,0,-1},{0,0,0},{0,1,-1},{0,1,0}},
00041 {{0,0,0},{0,0,1},{0,1,0},{0,1,1}},
00042
00043 {{-1,0,-1},{-1,0,0},{0,0,-1},{0,0,0}},
00044 {{-1,0,0},{-1,0,1},{0,0,0},{0,0,1}},
00045 {{0,0,-1},{0,0,0},{1,0,-1},{1,0,0}},
00046 {{0,0,0},{0,0,1},{1,0,0},{1,0,1}},
00047
00048 {{-1,-1,0},{-1,0,0},{0,-1,0},{0,0,0}},
00049 {{-1,0,0},{-1,1,0},{0,0,0},{0,1,0}},
00050 {{0,-1,0},{0,0,0},{1,-1,0},{1,0,0}},
00051 {{0,0,0},{0,1,0},{1,0,0},{1,1,0}}
00052 };
00053
00054 const int faceCells[12][2]={{0,4},{1,5},{2,6},{3,7},{0,2},{1,3},{4,6},{5,7},{0,1},{2,3},{4,5},{6,7}};
00055
00056 const int cubeFaces[6][4] =
00057 { {1,5,7,3},{0,2,6,4},{2,3,7,6},{0,4,5,1},{5,4,6,7},{0,1,3,2}};
00058
00059 const int faceEdges[12][2] = {{3,1},{3,0},{2,1},{2,0},
00060 {5,1},{5,0},{4,1},{4,0},
00061 {5,3},{5,2},{4,3},{4,2}};
00062
00063 const int edgeFaces[6][4] = {{1,3,5,7},{0,2,4,6},{2,3,9,11},{0,1,8,10},{6,7,10,11},{4,5,8,9}} ;
00064
00065 struct gridPoint
00066 {
00067 int x, y, z;
00068 };
00069
00070 class Volume {
00071 public:
00072 Volume(EMData* em);
00073 Volume(int x, int y, int z);
00074 Volume(int x, int y, int z, float val);
00075 Volume(int x, int y, int z, int offx, int offy, int offz, Volume * vol);
00076 ~Volume( );
00077
00078 EMData* get_emdata();
00079 float getSpacingX();
00080 float getSpacingY();
00081 float getSpacingZ();
00082 float getOriginX();
00083 float getOriginY();
00084 float getOriginZ();
00085 int getSizeX();
00086 int getSizeY();
00087 int getSizeZ();
00088 int getIndex(int x, int y, int z);
00089 double getDataAt( int x, int y, int z );
00090 double getDataAt( int index );
00091 void setSpacing(float spx, float spy, float spz );
00092 void setOrigin(float orgX, float orgY, float orgZ);
00093 void setDataAt( int x, int y, int z, double d );
00094 void setDataAt( int index, double d );
00095
00096
00097
00098
00099
00100
00101
00102 void pad (int padBy, double padValue);
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 int getNumNeighbor6(int ox, int oy, int oz);
00118
00119
00120
00121
00122
00123
00124
00125 int hasCell(int ox, int oy, int oz);
00126 Volume * markCellFace();
00127
00128 int hasCompleteSheet(int ox, int oy, int oz, Volume * fvol);
00129 int hasCompleteSheet(int ox, int oy, int oz);
00130
00131 int hasCompleteHelix(int ox, int oy, int oz);
00132 int hasCompleteHelix(int ox, int oy, int oz, Volume * fvol);
00133 int isHelixEnd(int ox, int oy, int oz, Volume * nvol);
00134
00135
00136
00137
00138
00139 int isHelixEnd(int ox, int oy, int oz);
00140 int isSheetEnd(int ox, int oy, int oz, Volume * nvol);
00141
00142
00143
00144
00145
00146 int isFeatureFace( int ox, int oy, int oz );
00147
00148 int isSheetEnd( int ox, int oy, int oz );
00149 int isSimple( int ox, int oy, int oz );
00150 int isPiercable( int ox, int oy, int oz );
00151
00152
00153
00154 int getNumPotComplex( int ox, int oy, int oz );
00155 int getNumPotComplex2( int ox, int oy, int oz );
00156
00157
00158 int components6( int vox[3][3][3] );
00159 int components26( int vox[3][3][3] );
00160 int countExt( double vox[3][3][3] );
00161 int countInt( double vox[3][3][3] );
00162 int countIntEuler( int ox, int oy, int oz );
00163
00164
00165
00166
00167
00168 void curveSkeleton( Volume* grayvol, float lowthr, float highthr, Volume* svol );
00169 void curveSkeleton( float thr, Volume* svol );
00170 void curveSkeleton2D( float thr, Volume* svol );
00171 void skeleton( float thr, int off );
00172
00173
00174 void skeleton( float thr, Volume* svol, Volume* hvol );
00175 void erodeHelix( );
00176 void erodeHelix( int disthr );
00177 int erodeSheet( );
00178 int erodeSheet( int disthr );
00179
00180
00181
00182
00183
00184
00185
00186
00187 void surfaceSkeletonPres( float thr, Volume * preserve );
00188
00189
00190
00191 void threshold( double thr );
00192 void threshold( double thr, int out, int in );
00193 void threshold( double thr, int out, int in, int boundary);
00194 void threshold( double thr, int out, int in, int boundary, bool markBoundary);
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 VolumeData * getVolumeData();
00220
00221 private:
00222 VolumeData * volData;
00223 };
00224
00225
00226
00227 }
00228 }
00229
00230 #endif