PolynomialBiasField.h
1 /*
2  * Developing brain Region Annotation With Expectation-Maximization (Draw-EM)
3  *
4  * Copyright 2013-2016 Imperial College London
5  * Copyright 2013-2016 Christian Ledig
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 MIRTKPOLYNOMIALBIASFIELD_H_
22 #define MIRTKPOLYNOMIALBIASFIELD_H_
23 
24 #include "mirtk/BiasField.h"
25 
26 namespace mirtk {
27 
28 class PolynomialBiasField : public BiasField
29 {
30  mirtkObjectMacro(PolynomialBiasField);
31 
32 private:
33  int _dop;
34  double* _coeff;
35  int _numOfCoefficients;
36 
37 public:
38  PolynomialBiasField();
39 
40  /**
41  * @param dop max degree of polynomial
42  */
43  PolynomialBiasField(const GreyImage &image, int dop);
44  ~PolynomialBiasField();
45 
46  /// Calculate weighted least square fit of polynomial to data
47  virtual void WeightedLeastSquares(double *x1, double *y1, double *z1, double *bias, double *weights, int no);
48 
49  double Bias(double, double, double);
50 
51  double Approximate(double *, double *, double *, double *, int);
52  void Interpolate(double* dbias);
53 
54  /// Subdivide FFD
55  void Subdivide();
56 
57  /// Reads FFD from file
58  void Read (char *);
59 
60  /// Writes FFD to file
61  virtual void Write(char *);
62 
63  /// Print info
64  virtual void Print();
65 
66 private:
67  double evaluatePolynomial(double x, double y, double z);
68  int getNumberOfCoefficients(int dop);
69 };
70 
71 }
72 
73 #endif /* MIRTKPOLYNOMIALBIASFIELD_H_ */
int Read(const char *name, UniquePtr< double[]> &data, int *dtype=nullptr, ImageAttributes *attr=nullptr, void *=nullptr, const char *scalars_name=nullptr, bool cell_data=false)
Read data sequence from any supported input file type.
Definition: IOConfig.h:41
std::ostream & Print(std::ostream &os, T value)
Print single argument to output stream.
Definition: String.h:259