NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkSequentialCpuQds.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkSequentialCpuQds_h
16 #define niftkSequentialCpuQds_h
17 
18 #include "niftkOpenCVExports.h"
19 #include "niftkQDSCommon.h"
20 #include <opencv2/core/types_c.h>
21 // FIXME: typedefs.hpp should be enough! but there seem to be some issues...
22 //#include <boost/gil/typedefs.hpp>
23 #include <boost/gil/gil_all.hpp>
24 #include <vector>
25 
26 #ifndef NIFTKOPENCV_EXPORT
27 #define NIFTKOPENCV_EXPORT
28 #endif
29 
30 namespace niftk
31 {
32 
34 {
35  int WinSizeX; // similarity window, in pixels
36  int WinSizeY;
37 
38  int BorderX; // border in pixels to ignore
39  int BorderY;
40 
41  float Ct; // correlation threshold
42  float Tt; // texture threshold
43 //float Et; // epipolar threshold
44 
45  int N; // search neighbourhood size, in pixels
46  int Dg; // disparity gradient threshold, in pixels
47 };
48 
49 
50 #ifdef _MSC_VER
51 // various bits rely on safely dll-exporting class members which may reference
52 // crt components (that may not be explicitly declared to be exported).
53 // this checks that we are building against the dll version of the crt.
54 #ifndef _DLL
55 #ifdef _MT
56 #error You are compiling against the static version of the CRT. This is not supported! Choose DLL instead!
57 #else
58 #pragma message("Warning: cannot tell which CRT version you are building with. Stuff might fail.")
59 #endif
60 #endif
61 
62 #pragma warning(push)
63 #pragma warning(disable: 4251) // class '...' needs to have dll-interface to be used by clients of class '...'
64 #endif
65 
67 {
68 
69 public:
70  SequentialCpuQds(int width, int height);
71  virtual ~SequentialCpuQds();
72 
73 
74  // supports greyscale, RGB or RGBA images.
75  // input dimensions need to match the width and height passed into constructor.
76  virtual void Process(const IplImage* left, const IplImage* right) override;
77 
78 
79  virtual int GetWidth() const override;
80  virtual int GetHeight() const override;
81 
82  // caller needs to clean up
83  virtual IplImage* CreateDisparityImage() const override;
84 
85  virtual CvPoint GetMatch(int x, int y) const override;
86 
87 private:
88  SequentialCpuQds(const SequentialCpuQds& copyme);
89  SequentialCpuQds& operator=(const SequentialCpuQds& assignme);
90 
91 
92 private:
93  void InitSparseFeatures();
94 
95  void QuasiDensePropagation();
96 
97 
98 private:
99  // internal buffers are of fixed size
100  int m_Width;
101  int m_Height;
102 
103  PropagationParameters m_PropagationParams;
104 
105  // internal buffers
106  // grayscale version of the input passed to Process()
107  boost::gil::gray8_image_t m_LeftImg;
108  boost::gil::gray8_image_t m_RightImg;
109  // integral image of the grayscale version
110  boost::gil::gray32s_image_t m_LeftIntegral;
111  boost::gil::gray32s_image_t m_RightIntegral;
112  // squared-integral
113  boost::gil::gray64f_image_t m_LeftSquaredIntegral;
114  boost::gil::gray64f_image_t m_RightSquaredIntegral;
115  // texture descriptor, i.e. cornerness image
116  boost::gil::gray8_image_t m_LeftTexture;
117  boost::gil::gray8_image_t m_RightTexture;
118  // refmap: pixel coordinate into the other view
119  boost::gil::dev2n16_image_t m_LeftRefMap;
120  boost::gil::dev2n16_image_t m_RightRefMap;
121 
122  // these have no mem allocated themselves!
123  // they only reference the gil images
124  IplImage m_LeftIpl;
125  IplImage m_RightIpl;
126  IplImage m_LeftIntegralIpl;
127  IplImage m_RightIntegralIpl;
128  IplImage m_LeftSquaredIntegralIpl;
129  IplImage m_RightSquaredIntegralIpl;
130 
131  static const int NUM_MAX_FEATURES = 500;
132  std::vector<CvPoint2D32f> m_SparseFeaturesLeft;
133  std::vector<CvPoint2D32f> m_SparseFeaturesRight;
134  std::vector<char> m_FeatureStatus;
135 
136  // used only for disparity image debugging
137  const int m_MaxDisparity;
138 };
139 
140 
141 #ifdef _MSC_VER
142 #pragma warning(pop)
143 #endif
144 
145 } // end namespace
146 
147 #endif
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1236
int WinSizeX
Definition: niftkSequentialCpuQds.h:35
int N
Definition: niftkSequentialCpuQds.h:45
int Dg
Definition: niftkSequentialCpuQds.h:46
Definition: niftkQDSCommon.h:97
float Tt
Definition: niftkSequentialCpuQds.h:42
int WinSizeY
Definition: niftkSequentialCpuQds.h:36
#define NIFTKOPENCV_EXPORT
Definition: niftkSequentialCpuQds.h:27
GLint left
Definition: glew.h:6793
Definition: niftkSequentialCpuQds.h:33
float Ct
Definition: niftkSequentialCpuQds.h:41
GLint GLint GLint GLint GLint x
Definition: glew.h:1236
int BorderX
Definition: niftkSequentialCpuQds.h:38
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
Definition: glew.h:1236
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1236
Definition: niftkSequentialCpuQds.h:66
int BorderY
Definition: niftkSequentialCpuQds.h:39
Definition: niftkExceptionObject.h:21