MeanShift.h
1 /*
2  * Developing brain Region Annotation With Expectation-Maximization (Draw-EM)
3  *
4  * Copyright 2013-2016 Imperial College London
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef _MIRTKMEANSHIFT_H
20 
21 #define _MIRTKMEANSHIFT_H
22 // queue::push/pop
23 
24 #include "mirtk/GenericImage.h"
25 #include "mirtk/Image.h"
26 #include "mirtk/Dilation.h"
27 #include "mirtk/Erosion.h"
28 #include "mirtk/Point.h"
29 #include "mirtk/GaussianBlurring.h"
30 #include <algorithm>
31 #include <queue>
32 
33 using namespace std;
34 namespace mirtk {
35 
36 class MeanShift
37 {
38 
39  int _nBins;
40  int _padding;
41  GreyImage _image;
42  queue<Point> _q;
43  GreyImage _map, _orig_image;
44  GreyImage *_brain;
45  GreyImage *_output;
46  GreyPixel _imin, _imax;
47  double _limit1, _limit2, _limit, _treshold;
48  double _bin_width;
49  double * _density;
50  int _clusterSize;
51 public:
52  double _bg,_wm,_gm,_split1,_split2;
53 
54 
55 public:
56 
57  MeanShift(GreyImage& image, int padding = -1, int nBins = 256);
58  ~MeanShift();
59  void SetOutput( GreyImage *_output);
60  double ValueToBin(double value);
61  double BinToValue(int bin);
62  void AddPoint(int x, int y, int z);
63  void AddPoint(int x, int y, int z, int label);
64  double msh(double y, double h);
65  double findMax(double tr1, double tr2);
66  double findMin(double tr1, double tr2);
67  double findGMvar();
68  double split(double pos1, double pos2, double bw, double h1, double h2);
69  double GenerateDensity(double cut_off=0.02);
70  void Grow(int x, int y, int z, int label);
71  int Lcc(int label, bool add_second = false);
72  int LccS(int label, double treshold = 0.5);
73  void RemoveBackground();
74  void RegionGrowing();
75  void FindWMGMmeans();
76  void Write(char *output_name);
77  void WriteMap(char *output_name);
78  void SetTreshold();
79  void SetTreshold(double treshold);
80 
81  RealImage ReturnMask();
82 };
83 
84 }
85 
86 #endif
87 
STL namespace.
Definition: IOConfig.h:41