ImageSurfaceStatistics.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2016 Imperial College London
5  * Copyright 2016 Andreas Schuh
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 #ifndef MIRTK_ImageSurfaceStatistics_H
21 #define MIRTK_ImageSurfaceStatistics_H
22 
23 #include "mirtk/SurfaceFilter.h"
24 
25 #include "mirtk/Array.h"
26 #include "mirtk/Memory.h"
27 #include "mirtk/DataStatistics.h"
28 #include "mirtk/InterpolateImageFunction.h"
29 
30 
31 namespace mirtk {
32 
33 
34 /**
35  * Extract image patches at surface mesh points and compute patch statistics
36  *
37  * This filter samples the values of a given image at a local patch centered at
38  * the points of a surface mesh and (optionally) computes common image statistics
39  * of these local image samples. The rectangular image patches can be either all
40  * aligned with the global world coordinate axes, the global image coordinate axes,
41  * or the local tangent space coordinate axes at each surface point.
42  */
44 {
45  mirtkObjectMacro(ImageSurfaceStatistics);
46 
47  // ---------------------------------------------------------------------------
48  // Types
49 public:
50 
51  enum Space
52  {
53  ImageSpace,
54  WorldSpace,
55  TangentSpace
56  };
57 
58  // ---------------------------------------------------------------------------
59  // Attributes
60 private:
61 
62  /// Continuous scalar image
63  mirtkPublicAttributeMacro(SharedPtr<const InterpolateImageFunction>, Image);
64 
65  /// Name of output point data array
66  mirtkPublicAttributeMacro(string, ArrayName);
67 
68  /// Coordinate system within which to extract image patches
69  mirtkPublicAttributeMacro(Space, PatchSpace);
70 
71  /// Size of each image patch centered at the mesh points
72  mirtkPublicAttributeMacro(int3, PatchSize);
73 
74  /// Spacing of patch samples in world units
75  mirtkPublicAttributeMacro(double3, PatchSpacing);
76 
77  /// Whether to include patch samples in output
78  mirtkPublicAttributeMacro(bool, PatchSamples);
79 
80  /// Whether to subtract mean of patch samples from sample values
81  mirtkPublicAttributeMacro(bool, DemeanSamples);
82 
83  /// Whether to divide sample values by standard deviation of patch samples
84  mirtkPublicAttributeMacro(bool, WhitenSamples);
85 
86  /// Functor objects used to compute desired patch statistics
87  mirtkPublicAttributeMacro(Array<SharedPtr<data::Statistic> >, Statistics);
88 
89  /// Copy attributes of this filter from another instance
90  void CopyAttributes(const ImageSurfaceStatistics &);
91 
92  // ---------------------------------------------------------------------------
93  // Construction/Destruction
94 
95 public:
96 
97  /// Default constructor
99 
100  /// Copy constructor
102 
103  /// Assignment operator
105 
106  /// Destructor
107  virtual ~ImageSurfaceStatistics();
108 
109  // ---------------------------------------------------------------------------
110  // Execution
111 
112 protected:
113 
114  /// Execute filter
115  virtual void Execute();
116 
117 private:
118 
119  /// Helper used for implementation of Execute function
120  template <class Body> void ExecuteInParallel(Body &);
121 
122 };
123 
124 
125 } // namespace mirtk
126 
127 #endif // MIRTK_ImageSurfaceStatistics_H
virtual ~ImageSurfaceStatistics()
Destructor.
Definition: IOConfig.h:41
virtual void Execute()
Execute filter.
ImageSurfaceStatistics & operator=(const ImageSurfaceStatistics &)
Assignment operator.
ImageSurfaceStatistics()
Default constructor.