EMAN2
volume.h
Go to the documentation of this file.
1// Copyright (C) 2005-2008 Washington University in St Louis, Baylor College of Medicine. All rights reserved
2// Author: Tao Ju (taoju@cse.wustl.edu), Refactored by Sasakthi Abeysinghe (sasakthi.abeysinghe@wustl.edu)
3// Description: Volumetric data definition
4
5#include "volume_data.h"
6//#include "ThinningTemplate.h"
7#include "grid_queue.h"
8#include "grid_queue2.h"
9//#include <cstdio>
10//#include <cstdlib>
11//#include <cmath>
12#include "priority_queue.h"
13//#include <vector>
14
15#ifndef SKELETON_MAKER_VOLUME_H
16#define SKELETON_MAKER_VOLUME_H
17
18#define MAX_SHEETS 100000
19#define MAX_QUEUELEN 5000000
20#define MAX_ERODE 1000
21
22using namespace std;
23
24namespace wustl_mm {
25 namespace SkeletonMaker {
26
27 const int neighbor6[6][3]={{0,0,1},{0,0,-1},{0,1,0},{0,-1,0},{1,0,0},{-1,0,0}} ;
28 const int neighbor4[4][2]={{0,1},{0,-1},{1,0},{-1,0}} ;
29 const int neighbor64[6][4][3] = {
30 {{0,1,0},{0,-1,0},{1,0,0},{-1,0,0}},
31 {{0,1,0},{0,-1,0},{1,0,0},{-1,0,0}},
32 {{0,0,1},{0,0,-1},{1,0,0},{-1,0,0}},
33 {{0,0,1},{0,0,-1},{1,0,0},{-1,0,0}},
34 {{0,0,1},{0,0,-1},{0,1,0},{0,-1,0}},
35 {{0,0,1},{0,0,-1},{0,1,0},{0,-1,0}}} ;
36
37 const int sheetNeighbor[12][4][3] = {
38 {{0,-1,-1},{0,-1,0},{0,0,-1},{0,0,0}},
39 {{0,-1,0},{0,-1,1},{0,0,0},{0,0,1}},
40 {{0,0,-1},{0,0,0},{0,1,-1},{0,1,0}},
41 {{0,0,0},{0,0,1},{0,1,0},{0,1,1}},
42
43 {{-1,0,-1},{-1,0,0},{0,0,-1},{0,0,0}},
44 {{-1,0,0},{-1,0,1},{0,0,0},{0,0,1}},
45 {{0,0,-1},{0,0,0},{1,0,-1},{1,0,0}},
46 {{0,0,0},{0,0,1},{1,0,0},{1,0,1}},
47
48 {{-1,-1,0},{-1,0,0},{0,-1,0},{0,0,0}},
49 {{-1,0,0},{-1,1,0},{0,0,0},{0,1,0}},
50 {{0,-1,0},{0,0,0},{1,-1,0},{1,0,0}},
51 {{0,0,0},{0,1,0},{1,0,0},{1,1,0}}
52 };
53
54 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}};
55
56 const int cubeFaces[6][4] =
57 { {1,5,7,3},{0,2,6,4},{2,3,7,6},{0,4,5,1},{5,4,6,7},{0,1,3,2}};
58
59 const int faceEdges[12][2] = {{3,1},{3,0},{2,1},{2,0},
60 {5,1},{5,0},{4,1},{4,0},
61 {5,3},{5,2},{4,3},{4,2}};
62
63 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}} ;
64
65 struct gridPoint
66 {
67 int x, y, z;
68 };
69
70 class Volume {
71 public:
72 Volume(EMData* em);//eman2
73 Volume(int x, int y, int z);
74 Volume(int x, int y, int z, float val);
75 Volume(int x, int y, int z, int offx, int offy, int offz, Volume * vol);
76 ~Volume( );
77
78 EMData* get_emdata(); //eman2
79 float getSpacingX();
80 float getSpacingY();
81 float getSpacingZ();
82 float getOriginX();
83 float getOriginY();
84 float getOriginZ();
85 int getSizeX();
86 int getSizeY();
87 int getSizeZ();
88 int getIndex(int x, int y, int z);
89 double getDataAt( int x, int y, int z );
90 double getDataAt( int index );
91 void setSpacing(float spx, float spy, float spz );
92 void setOrigin(float orgX, float orgY, float orgZ);
93 void setDataAt( int x, int y, int z, double d );
94 void setDataAt( int index, double d );
95
96
97 //Volume * getPseudoDensity();
98 //Volume * getDistanceField(int rad, float randf);
99 //int getNonZeroVoxelCount();
100 //void print();
101 //void subtract(Volume * vol);
102 void pad (int padBy, double padValue);
103 //void applyMask(Volume * maskVol, double maskValue, bool keepMaskValue);
104 //double getMin();
105 //double getMax();
106 //double getMaxValuePosition(int& maxX, int& maxY, int& maxZ);
107 //double getLocalMax(int x, int y, int z, int radius);
108 //double getLocalMin(int x, int y, int z, int radius);
109 //void fill(double val);
110 //int isBertrandBorder(int ox, int oy, int oz, int dir);
111 //int isBertrandEndPoint(int ox, int oy, int oz);
112 //int isHelix(int ox, int oy, int oz);
113 //int isSheet(int ox, int oy, int oz);
114 //Volume * getSheets(int minSize);
115 //Volume * getHelices(int minSize);
116 //int isEndPoint(int ox, int oy, int oz);
117 int getNumNeighbor6(int ox, int oy, int oz);
118 //int testIsSheetEnd(int ox, int oy, int oz);
119 //int isNoiseSheetEnd(int ox, int oy, int oz);
120 //int isInternal(int ox, int oy, int oz);
121 //int isInternal2(int ox, int oy, int oz);
122 //int hasIsolatedFace(int ox, int oy, int oz);
123 //int hasIsolatedEdge(int ox, int oy, int oz);
124 //int countFace(int ox, int oy, int oz, int m);
125 int hasCell(int ox, int oy, int oz);
127 //Volume * markFaceEdge();
128 int hasCompleteSheet(int ox, int oy, int oz, Volume * fvol);
129 int hasCompleteSheet(int ox, int oy, int oz);
130 //int hasCompleteSheetSlow(int ox, int oy, int oz);
131 int hasCompleteHelix(int ox, int oy, int oz);
132 int hasCompleteHelix(int ox, int oy, int oz, Volume * fvol);
133 int isHelixEnd(int ox, int oy, int oz, Volume * nvol);
134 //int isFeature18(int ox, int oy, int oz);
135 //int isEdgeEnd(int ox, int oy, int oz);
136 //int isFaceEnd(int ox, int oy, int oz);
137 //int isNoise(int ox, int oy, int oz, int noise);
138 //int isNoiseHelixEnd(int ox, int oy, int oz);
139 int isHelixEnd(int ox, int oy, int oz);
140 int isSheetEnd(int ox, int oy, int oz, Volume * nvol);
141 //int getNumFaces( int ox, int oy, int oz );
142 //int getNumCells( int ox, int oy, int oz );
143 //int getNumIsolatedEdges( int ox, int oy, int oz );
144 //int getNumIsolatedFaces( int ox, int oy, int oz );
145 //int isFeatureFace2( int ox, int oy, int oz );
146 int isFeatureFace( int ox, int oy, int oz );
147 //int hasFeatureFace( int ox, int oy, int oz );
148 int isSheetEnd( int ox, int oy, int oz );
149 int isSimple( int ox, int oy, int oz );
150 int isPiercable( int ox, int oy, int oz );
151 //int isSimple2( int v[3][3][3] );
152 //int getNumPotComplex3( int ox, int oy, int oz );
153 //int getNumPotComplex4( int ox, int oy, int oz );
154 int getNumPotComplex( int ox, int oy, int oz );
155 int getNumPotComplex2( int ox, int oy, int oz );
156 //int getNumNeighbor( int ox, int oy, int oz );
157 //void setScoreNeighbor( GridQueue* queue );
158 int components6( int vox[3][3][3] );
159 int components26( int vox[3][3][3] );
160 int countExt( double vox[3][3][3] );
161 int countInt( double vox[3][3][3] );
162 int countIntEuler( int ox, int oy, int oz );
163 //void erodeNoTopo( float thr, int wid );
164 //void erodeTopo( float thr, int wid );
165 //void erode2( float thr, int wid );
166 //void erodeShapeTopo( float thr, int wid );
167 //void erodeAtom( float thr, int wid, Volume* avol );
168 void curveSkeleton( Volume* grayvol, float lowthr, float highthr, Volume* svol );
169 void curveSkeleton( float thr, Volume* svol );
170 void curveSkeleton2D( float thr, Volume* svol );
171 void skeleton( float thr, int off );
172 //void skeleton2( float thr, int off );
173 //void pointSkeleton( Volume* grayvol, float lowthr, float highthr, Volume* svol, Volume* hvol );
174 void skeleton( float thr, Volume* svol, Volume* hvol );
175 void erodeHelix( );
176 void erodeHelix( int disthr );
177 int erodeSheet( );
178 int erodeSheet( int disthr );
179 //void erodeSheetOld( int disthr );
180 //void addNoise( float thr, float pos );
181 //void sequentialSkeleton( float thr, int type, int noise );
182 //void dumbsurfaceSkeleton( float thr );
183 //void surfaceSkeleton( Volume* grayvol, float lowthr, float highthr );
184 //void surfaceSkeleton( float thr );
185 //void surfaceSkeleton( float thr, Volume* svol );
186 //void surfaceSkeletonOld( float thr );
187 void surfaceSkeletonPres( float thr, Volume * preserve );
188 //void bertrandSurfaceSkeleton2( float thr );
189 //void bertrandSurfaceSkeleton( float thr );
190 //void palagyiSurfaceSkeleton( float thr );
191 void threshold( double thr );
192 void threshold( double thr, int out, int in );
193 void threshold( double thr, int out, int in, int boundary);
194 void threshold( double thr, int out, int in, int boundary, bool markBoundary);
195 //void threshold2( double thr, int out, int in );
196 //void smooth( float alpha );
197 //void normalize( double min, double max );
198 //void normalize( double min, double max, double thresh, double ithresh );
199 //Volume * getDataRange(int x, int y, int z, int radius);
200 //double getInterpDataAt( double x, double y, double z );
201 //void rotateX ( double a );
202 //void toMathematicaFile( char* fname );
203 //void toMathematicaFile( char* fname, int lx, int hx, int ly, int hy, int lz, int hz );
204 //void toOFFCells( char* fname );
205 //void toOFFCells2( char* fname );
206 //void toOFFCells2( char* fname, float thr );
207 //void toOFFCells( char* fname, float thr );
208 //void segment( float threshold, Volume* lowvol, Volume* highvol, char* mrcfile );
209 //void segment( float threshold, Volume* vol, int maxDis, char* mrcfile );
210 //void writeSegmentation( float threshold, Volume* segvol, char* txtfile, char* mrcfile );
211 //void floodFill( float thr );
212 //void reduceComponent( int size );
213 //void reduceComponent2( int num );
214 //void floodFillPQR( int offset );
215 //void writeDistances( char* fname, int maxDis );
216 //void toPQRFile( char* fname, float spc, float minx, float miny, float minz, int padding );
217 //void toMRCFile( char* fname );
218 //private:
220
221 private:
223 };
224
225
226
227 }
228}
229
230#endif
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
void skeleton(float thr, int off)
Definition: volume.cpp:5089
int components6(int vox[3][3][3])
Definition: volume.cpp:2698
int isHelixEnd(int ox, int oy, int oz, Volume *nvol)
Definition: volume.cpp:1579
void setOrigin(float orgX, float orgY, float orgZ)
Definition: volume.cpp:77
int isSimple(int ox, int oy, int oz)
Definition: volume.cpp:2316
int countInt(double vox[3][3][3])
Definition: volume.cpp:2859
int getIndex(int x, int y, int z)
Definition: volume.cpp:48
int hasCell(int ox, int oy, int oz)
Definition: volume.cpp:1016
int countIntEuler(int ox, int oy, int oz)
Definition: volume.cpp:2895
int isPiercable(int ox, int oy, int oz)
Definition: volume.cpp:2381
void pad(int padBy, double padValue)
Definition: volume.cpp:273
int isSheetEnd(int ox, int oy, int oz, Volume *nvol)
Definition: volume.cpp:1821
int getNumPotComplex(int ox, int oy, int oz)
Definition: volume.cpp:2548
int hasCompleteHelix(int ox, int oy, int oz)
Definition: volume.cpp:1456
void curveSkeleton(Volume *grayvol, float lowthr, float highthr, Volume *svol)
insert them back into priority queue
Definition: volume.cpp:3812
int components26(int vox[3][3][3])
Definition: volume.cpp:2767
void surfaceSkeletonPres(float thr, Volume *preserve)
for ( int m = 0 ; m < 6 ; m ++ )
Definition: volume.cpp:8672
int countExt(double vox[3][3][3])
Definition: volume.cpp:2838
int getNumPotComplex2(int ox, int oy, int oz)
Definition: volume.cpp:2615
int hasCompleteSheet(int ox, int oy, int oz, Volume *fvol)
Definition: volume.cpp:1174
int isFeatureFace(int ox, int oy, int oz)
Definition: volume.cpp:2135
void curveSkeleton2D(float thr, Volume *svol)
Definition: volume.cpp:4678
void threshold(double thr)
Definition: volume.cpp:9515
double getDataAt(int x, int y, int z)
Definition: volume.cpp:60
void setSpacing(float spx, float spy, float spz)
Definition: volume.cpp:73
int getNumNeighbor6(int ox, int oy, int oz)
Definition: volume.cpp:661
void setDataAt(int x, int y, int z, double d)
Definition: volume.cpp:52
VolumeData * getVolumeData()
Definition: volume.cpp:69
const int neighbor64[6][4][3]
Definition: volume.h:29
const int neighbor6[6][3]
Definition: volume.h:27
const int edgeFaces[6][4]
Definition: volume.h:63
const int faceCells[12][2]
Definition: volume.h:54
const int cubeFaces[6][4]
Definition: volume.h:56
const int sheetNeighbor[12][4][3]
Definition: volume.h:37
const int faceEdges[12][2]
Definition: volume.h:59
const int neighbor4[4][2]
Definition: volume.h:28
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517