24 #include "mirtk/EMBase.h" 26 #include "mirtk/PolynomialBiasField.h" 27 #include "mirtk/Image.h" 28 #include "mirtk/HashProbabilisticAtlas.h" 29 #include "mirtk/BiasField.h" 30 #include "mirtk/BiasCorrection.h" 31 #include "mirtk/Image.h" 32 #include "mirtk/GaussianBlurring.h" 33 #include "mirtk/EuclideanDistanceTransform.h" 34 #include "mirtk/ConnectedComponents.h" 43 class DrawEM :
public EMBase
45 mirtkObjectMacro(DrawEM);
51 RealImage _MRF_weights;
54 RealImage _uncorrected;
57 BiasCorrection _biascorrection;
60 BiasField *_biasfield;
66 map<int,int> pv_classes;
67 vector< pair<int, int> > pv_connections;
77 double beta,betainter;
81 RealImage **_MRF_inter;
85 int csflabel,wmlabel,gmlabel,outlabel;
88 bool isPVclass(
int pvclass);
89 double getMRFenergy(
int index,
int tissue);
90 double getMRFInterEnergy(
int index,
int tissue);
95 template <
class ImageType>
96 DrawEM(
int noTissues, ImageType **atlas, ImageType *background);
97 template <
class ImageType>
98 DrawEM(
int noTissues, ImageType **atlas);
99 template <
class ImageType>
100 DrawEM(
int noTissues, ImageType **atlas, ImageType **initposteriors);
103 void InitialiseParameters();
106 void GetBiasField(RealImage &image);
109 int AddPartialVolumeClass(
int classA,
int classB,
int huiclass=0);
116 void RStep(
double rf);
119 virtual void BStep();
123 using EMBase::SetInput;
128 virtual void SetInput(
const RealImage &,
const Matrix &);
131 virtual void SetBiasField(BiasField *);
134 virtual double Iterate(
int iteration);
137 virtual void GetBiasCorrectedImage(RealImage &);
141 virtual void setMRFstrength(
double mrfw);
143 virtual void setbignn(
bool bnn);
145 double getMRFenergy_diag(
int index,
int tissue);
151 void setTissueLabels(
int num,
int *atisslabels);
154 void setHui(
bool hui);
156 void huiPVCorrection(
bool changePosterior=
false);
158 void ConstructSegmentationHui(IntegerImage &segmentation);
161 void getHuiValues(
double &outval,
double &csfval,
double &gmval,
double &wmval,
int x,
int y,
int z,
bool atlas);
164 void setHuiValues(
double &outval,
double &csfval,
double &gmval,
double &wmval,
int x,
int y,
int z,
bool atlas);
167 virtual void setBeta(
double beta);
169 virtual void setBetaInter(
double betainter);
171 virtual void setMRFInterAtlas(RealImage **&atlas);
175 inline void DrawEM::setHui(
bool hui){huipvcorr=hui;}
176 inline void DrawEM::setbignn(
bool bnn){bignn=bnn;}
177 inline void DrawEM::setMRFstrength(
double mrfw){mrfweight=mrfw;}
178 inline void DrawEM::setMRFInterAtlas(RealImage **&atlas){ _MRF_inter=atlas; intermrf=
true;}
179 inline void DrawEM::setBeta(
double b){beta=b;}
180 inline void DrawEM::setBetaInter(
double b){betainter=b;}
181 inline void DrawEM::setTissueLabels(
int num,
int *atisslabels){
182 tissuelabels=
new int[num];
183 for(
int i=0;i<num;i++) tissuelabels[i]=atisslabels[i];