BiasCorrection.h
1 /*
2  * Developing brain Region Annotation With Expectation-Maximization (Draw-EM)
3  *
4  * Copyright 2013-2016 Imperial College London
5  * Copyright 2013-2016 Daniel Rueckert
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 
21 #ifndef _MIRTKBIASCORRECTION_H
22 
23 #define _MIRTKBIASCORRECTION_H
24 
25 #include "mirtk/Image.h"
26 
27 #include "mirtk/Resampling.h"
28 
29 #include "mirtk/Transformation.h"
30 
31 #include "mirtk/BiasField.h"
32 
33 namespace mirtk {
34 
35 class BiasCorrection : public Object
36 {
37  mirtkObjectMacro(BiasCorrection);
38 
39 protected:
40 
41  RealImage *_target;
42 
43  RealImage *_reference;
44 
45  RealImage *_weights;
46  ByteImage *_mask;
47 
48  /// Output
49  BiasField *_biasfield;
50 
51  /// Padding value
52  GreyPixel _Padding;
53 
54  /// Initial set up for the registration
55  virtual void Initialize();
56 
57  /// Final set up for the registration
58  virtual void Finalize();
59 
60 public:
61 
62  /// Constructor
63  BiasCorrection();
64 
65  /// Destructor
66  virtual ~BiasCorrection();
67 
68  /// Sets input for the bias correction filter
69  virtual void SetInput (RealImage *, RealImage *);
70 
71  /// Sets weights for the bias correction filter
72  virtual void SetWeights (RealImage *);
73 
74  /// Sets output for the bias correction filter
75  virtual void SetOutput(BiasField *);
76 
77  virtual void SetMask( ByteImage *);
78 
79  /// Runs the bias correction filter
80  virtual void Run();
81 
82  /// Apply bias correction to _input
83  virtual void Apply(RealImage &);
84 
85  /// Apply bias correction to any image
86  virtual void ApplyToImage(RealImage &);
87 
88  /// Apply bias correction to any image including logarithmic transform
89  virtual void ApplyToImage(GreyImage &);
90 
91  // Access parameters
92  virtual void SetPadding(short Padding);
93  virtual short GetPadding();
94 
95 };
96 
97 inline void BiasCorrection::SetInput(RealImage *target, RealImage *reference)
98 {
99  _target = target;
100  _reference = reference;
101 }
102 
103 inline void BiasCorrection::SetWeights(RealImage *weights)
104 {
105  _weights = weights;
106 }
107 
108 inline void BiasCorrection::SetOutput(BiasField *biasfield)
109 {
110  _biasfield = biasfield;
111 }
112 
113 inline void BiasCorrection::SetPadding(short Padding)
114 {
115  _Padding = Padding;
116 }
117 inline short BiasCorrection::GetPadding(){
118  return _Padding;
119 }
120 
121 }
122 #endif
Definition: IOConfig.h:41