volume.h

Go to the documentation of this file.
00001 // Copyright (C) 2005-2008 Washington University in St Louis, Baylor College of Medicine.  All rights reserved
00002 // Author:        Tao Ju (taoju@cse.wustl.edu), Refactored by Sasakthi Abeysinghe (sasakthi.abeysinghe@wustl.edu)
00003 // Description:   Volumetric data definition
00004 
00005 #include "volume_data.h"
00006 //#include "ThinningTemplate.h"
00007 #include "grid_queue.h"
00008 #include "grid_queue2.h"
00009 //#include <cstdio>
00010 //#include <cstdlib>
00011 //#include <cmath>
00012 #include "priority_queue.h"
00013 //#include <vector>
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);//eman2
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(); //eman2
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                         //Volume * getPseudoDensity();
00098                         //Volume * getDistanceField(int rad, float randf);
00099                         //int getNonZeroVoxelCount();
00100                         //void print();
00101                         //void subtract(Volume * vol);
00102                         void pad (int padBy, double padValue);
00103                         //void applyMask(Volume * maskVol, double maskValue, bool keepMaskValue);
00104                         //double getMin();
00105                         //double getMax();
00106                         //double getMaxValuePosition(int& maxX, int& maxY, int& maxZ);
00107                         //double getLocalMax(int x, int y, int z, int radius);
00108                         //double getLocalMin(int x, int y, int z, int radius);
00109                         //void fill(double val);
00110                         //int isBertrandBorder(int ox, int oy, int oz, int dir);
00111                         //int isBertrandEndPoint(int ox, int oy, int oz);
00112                         //int isHelix(int ox, int oy, int oz);
00113                         //int isSheet(int ox, int oy, int oz);
00114                         //Volume * getSheets(int minSize);
00115                         //Volume * getHelices(int minSize);
00116                         //int isEndPoint(int ox, int oy, int oz);
00117                         int getNumNeighbor6(int ox, int oy, int oz);
00118                         //int testIsSheetEnd(int ox, int oy, int oz);
00119                         //int isNoiseSheetEnd(int ox, int oy, int oz);
00120                         //int isInternal(int ox, int oy, int oz);
00121                         //int isInternal2(int ox, int oy, int oz);
00122                         //int hasIsolatedFace(int ox, int oy, int oz);
00123                         //int hasIsolatedEdge(int ox, int oy, int oz);
00124                         //int countFace(int ox, int oy, int oz, int m);
00125                         int hasCell(int ox, int oy, int oz);
00126                         Volume * markCellFace();
00127                         //Volume * markFaceEdge();
00128                         int hasCompleteSheet(int ox, int oy, int oz, Volume * fvol);
00129                         int hasCompleteSheet(int ox, int oy, int oz);
00130                         //int hasCompleteSheetSlow(int ox, int oy, int oz);
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                         //int isFeature18(int ox, int oy, int oz);
00135                         //int isEdgeEnd(int ox, int oy, int oz);
00136                         //int isFaceEnd(int ox, int oy, int oz);
00137                         //int isNoise(int ox, int oy, int oz, int noise);
00138                         //int isNoiseHelixEnd(int ox, int oy, int oz);
00139                         int isHelixEnd(int ox, int oy, int oz);
00140                         int isSheetEnd(int ox, int oy, int oz, Volume * nvol);
00141                         //int getNumFaces( int ox, int oy, int oz );
00142                         //int getNumCells( int ox, int oy, int oz );
00143                         //int getNumIsolatedEdges( int ox, int oy, int oz );
00144                         //int getNumIsolatedFaces( int ox, int oy, int oz );
00145                         //int isFeatureFace2( int ox, int oy, int oz );
00146                         int isFeatureFace( int ox, int oy, int oz );
00147                         //int hasFeatureFace( int ox, int oy, int oz );
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                         //int isSimple2( int v[3][3][3] );
00152                         //int getNumPotComplex3( int ox, int oy, int oz );
00153                         //int getNumPotComplex4( int ox, int oy, int oz );
00154                         int getNumPotComplex( int ox, int oy, int oz );
00155                         int getNumPotComplex2( int ox, int oy, int oz );
00156                         //int getNumNeighbor( int ox, int oy, int oz );
00157                         //void setScoreNeighbor( GridQueue* queue );
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                         //void erodeNoTopo( float thr, int wid );
00164                         //void erodeTopo( float thr, int wid );
00165                         //void erode2( float thr, int wid );
00166                         //void erodeShapeTopo( float thr, int wid );
00167                         //void erodeAtom( float thr, int wid, Volume* avol );
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                         //void skeleton2( float thr, int off );
00173                         //void pointSkeleton( Volume* grayvol, float lowthr, float highthr, Volume* svol, Volume* hvol );
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                         //void erodeSheetOld( int disthr );
00180                         //void addNoise( float thr, float pos );
00181                         //void sequentialSkeleton( float thr, int type, int noise );
00182                         //void dumbsurfaceSkeleton( float thr );
00183                         //void surfaceSkeleton( Volume* grayvol, float lowthr, float highthr );
00184                         //void surfaceSkeleton( float thr );
00185                         //void surfaceSkeleton( float thr, Volume* svol );
00186                         //void surfaceSkeletonOld( float thr );
00187                         void surfaceSkeletonPres( float thr, Volume * preserve );
00188                         //void bertrandSurfaceSkeleton2( float thr );
00189                         //void bertrandSurfaceSkeleton( float thr );
00190                         //void palagyiSurfaceSkeleton( float thr );
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                         //void threshold2( double thr, int out, int in );
00196                         //void smooth( float alpha );
00197                         //void normalize( double min, double max );
00198                         //void normalize( double min, double max, double thresh, double ithresh );
00199                         //Volume * getDataRange(int x, int y, int z, int radius);
00200                         //double getInterpDataAt( double x, double y, double z );
00201                         //void rotateX ( double a );
00202                         //void toMathematicaFile( char* fname );
00203                         //void toMathematicaFile( char* fname, int lx, int hx, int ly, int hy, int lz, int hz );
00204                         //void toOFFCells( char* fname );
00205                         //void toOFFCells2( char* fname );
00206                         //void toOFFCells2( char* fname, float thr );
00207                         //void toOFFCells( char* fname, float thr );
00208                         //void segment( float threshold, Volume* lowvol, Volume* highvol, char* mrcfile );
00209                         //void segment( float threshold, Volume* vol, int maxDis, char* mrcfile );
00210                         //void writeSegmentation( float threshold, Volume* segvol, char* txtfile, char* mrcfile );
00211                         //void floodFill( float thr );
00212                         //void reduceComponent( int size );
00213                         //void reduceComponent2( int num );
00214                         //void floodFillPQR( int offset );
00215                         //void writeDistances( char* fname, int maxDis );
00216                         //void toPQRFile( char* fname, float spc, float minx, float miny, float minz, int padding );
00217                         //void toMRCFile( char* fname );
00218                 //private:
00219                         VolumeData * getVolumeData();
00220 
00221                 private:
00222                         VolumeData * volData;
00223                 };
00224 
00225 
00226 
00227         }
00228 }
00229 
00230 #endif

Generated on Tue Jun 11 12:40:27 2013 for EMAN2 by  doxygen 1.4.7