Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
SFLSSegmentor3D.h
Go to the documentation of this file.
1#ifndef SFLSSegmentor3D_h_
2#define SFLSSegmentor3D_h_
3
4#include "SFLS.h"
5
6#include <list>
7#include <vector>
8
9// douher
10// #include "cArray3D.h"
11
12// itk
13#include "itkImage.h"
14
15template <typename TPixel>
16class CSFLSSegmentor3D : public CSFLS
17{
18public:
19 typedef CSFLSSegmentor3D<TPixel> Self;
20
22
25 // typedef boost::shared_ptr< Self > Pointer;
26
27 typedef itk::Image<TPixel, 3> TImage;
28 typedef itk::Image<float, 3> TFloatImage;
29 typedef itk::Image<double, 3> TDoubleImage;
30 typedef itk::Image<char, 3> TCharImage;
31 typedef itk::Image<unsigned char, 3> TUCharImage;
32 typedef itk::Image<short, 3> TShortImage;
33
39
40 typedef typename TImage::IndexType TIndex;
41 typedef typename TImage::SizeType TSize;
42 typedef typename TImage::RegionType TRegion;
43
45 virtual ~CSFLSSegmentor3D() = default;
46
47 /* New */
48 // static Pointer New() { return Pointer(new Self); }
49
50 /* ============================================================
51 * functions */
52 void basicInit();
53
54 void setNumIter(unsigned long n);
55
56 void setImage(typename ImageType::Pointer img);
57 void setMask(typename MaskImageType::Pointer mask);
58
59 virtual void computeForce() = 0;
60
62
63 // double maxPhi(long ix, long iy, long iz, double level);
64 // double minPhi(long ix, long iy, long iz, double level);
65 bool getPhiOfTheNbhdWhoIsClosestToZeroLevelInLayerCloserToZeroLevel(long ix, long iy, long iz, double& thePhi);
66
68
69 // void getSFLSFromPhi();
70
72 {
74 }
75 void initializeSFLSFromMask(); // m_insideVoxelCount is first computed here
76
78
80
81 virtual void doSegmenation() = 0;
82
83 // geometry
84 double computeKappa(long ix, long iy, long iz);
85
86 void setMaxVolume(double v); // v is in mL
87
88 void setMaxRunningTime(double t); // t in min
89
90 // about evolution history
92 {
94 }
96
97 void writeZeroLayerAtIterationToFile(unsigned long i, const char* name);
98
99 void writeZeroLayerToFile(const char* namePrefix);
100
101 void setCurvatureWeight(double a);
102
103 LSImageType::Pointer getLevelSetFunction();
104
105 /* ============================================================
106 * data */
107 // CSFLS::Pointer mp_sfls;
108
109 typename ImageType::Pointer mp_img;
110 typename LabelImageType::Pointer mp_label;
111 typename MaskImageType::Pointer mp_mask; // 0, non-0 mask for object
112 typename LSImageType::Pointer mp_phi;
113
114 // std::list< double > m_force;
115 std::vector<double> m_force;
116
118
119 unsigned long m_numIter;
120protected:
122
123 bool m_done;
124
125 long m_nx;
126 long m_ny;
127 long m_nz;
128
129 double m_dx; // in mm
130 double m_dy; // in mm
131 double m_dz; // in mm
132
135
136 double m_maxVolume; // max physical volume, in mm^3
137 double m_maxRunningTime; // in sec
138
139 /*----------------------------------------------------------------------
140 These two record the pts which change status
141
142 Because they are created and visited sequentially, and when not
143 needed, are clear-ed as a whole. No random insertion or removal is
144 needed. So use vector is faster than list. */
147
149
150 inline bool doubleEqual(double a, double b, double eps = 1e-10)
151 {
152 return a - b < eps && b - a < eps;
153 }
154
156 std::vector<CSFLSLayer> m_zeroLayerHistory;
157
158};
159
160#include "SFLSSegmentor3D.txx"
161
162#endif
CSFLSSegmentor3D< TPixel > Self
itk::Image< float, 3 > TFloatImage
TImage::RegionType TRegion
itk::Image< double, 3 > TDoubleImage
LSImageType::Pointer mp_phi
itk::Image< TPixel, 3 > TImage
void keepZeroLayerHistory(bool b)
bool getPhiOfTheNbhdWhoIsClosestToZeroLevelInLayerCloserToZeroLevel(long ix, long iy, long iz, double &thePhi)
void initializeLabel()
void setCurvatureWeight(double a)
void writeZeroLayerToFile(const char *namePrefix)
TFloatImage LSImageType
MaskImageType::Pointer mp_mask
TShortImage ShortImageType
void oneStepLevelSetEvolution()
LabelImageType::Pointer mp_label
SuperClassType::CSFLSLayer CSFLSLayer
TCharImage LabelImageType
TImage::IndexType TIndex
virtual void doSegmenation()=0
virtual ~CSFLSSegmentor3D()=default
bool doubleEqual(double a, double b, double eps=1e-10)
CSFLSLayer getZeroLayerAtIteration(unsigned long i)
void writeZeroLayerAtIterationToFile(unsigned long i, const char *name)
double computeKappa(long ix, long iy, long iz)
void setMask(typename MaskImageType::Pointer mask)
std::vector< double > m_force
TImage::SizeType TSize
void setImage(typename ImageType::Pointer img)
void setMaxVolume(double v)
LSImageType::Pointer getLevelSetFunction()
void setMaxRunningTime(double t)
void setNumIter(unsigned long n)
unsigned long m_numIter
void updateInsideVoxelCount()
ImageType::Pointer mp_img
itk::Image< unsigned char, 3 > TUCharImage
std::vector< CSFLSLayer > m_zeroLayerHistory
virtual void computeForce()=0
SuperClassType::NodeType NodeType
TUCharImage MaskImageType
itk::Image< char, 3 > TCharImage
itk::Image< short, 3 > TShortImage
void initializeSFLSFromMask()
Definition SFLS.h:11
std::list< NodeType > CSFLSLayer
Definition SFLS.h:16
vnl_vector_fixed< int, 3 > NodeType
Definition SFLS.h:15