OPAL
OPAL.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include "ImageDatabase.h"
13 #include "OPALSettings.h"
14 #include "SSD.h"
15 #include "MaxVoteLabelEstimator.h"
16 #include "DummyLabelEstimator.h"
17 
18 #include <chrono>
19 #include <random>
20 #include <functional>
21 
34 class OPAL {
35 public:
36  // Fixed types.
37  using ImgPixelType = double;
38  using SegPixelType = int;
42  using SSDType = SSD<DatabaseType>;
43 
49  OPAL(const OPALSettings &settings, const DatabaseType &database);
50 
62 
63  void BuildSegmentation();
64 
66  SegType GetOutput() const {
67  return OutputSegmentation;
68  }
69 
73  void Run();
74 
75 
77  const Image<int>& getFieldX() const { return FieldX; }
78 
80  const Image<int>& getFieldY() const { return FieldY; }
81 
83  const Image<size_t>& getFieldT() const { return FieldT; }
84 
86  const Image<SSDType>& getSSDMap() const { return SSDMap; }
87 
88 
89 private:
91  const OPALSettings &Sets;
92 
94  const DatabaseType &Database;
95 
96  // Output displacement fields.
97  Image<int> FieldX;
98  Image<int> FieldY;
99  Image<size_t> FieldT;
100  Image<SSDType> SSDMap;
101 
102  // Size of the images in the database. Just to replace call to
103  // Database.getImageHeight(), Database.getImageWidth().
104  size_t ImageHeight;
105  size_t ImageWidth;
106 
113  ImgType InputImage;
114 
116  SegType OutputSegmentation;
117 
118 
119  using RandomGeneratorType = std::mt19937;
120 
122  RandomGeneratorType randGen;
123 
124 
126  using CandidateLabelsContainer = FinalLabelEstimator::CandidateContainer;
127  FinalLabelEstimator finalLabelEstimator;
128 
129 private:
135  void EvenPropagation(size_t iteration);
136 
142  void OddPropagation(size_t iteration);
143 
150  int PropagateRightDown(size_t x, size_t y);
151 
158  int PropagateLeftUp(size_t x, size_t y);
159 
161  void SaveCurrentFields(const std::string &fileName) const;
162 
171  SSDType SSDAt(size_t i, size_t j) const;
172 
174  void UpdateSSDMap();
175 
176  void GetCandidateLabelsForPixel(size_t i, size_t j,
177  CandidateLabelsContainer &result) const;
178 };
const Image< size_t > & getFieldT() const
Definition: OPAL.h:83
Definition: ImageDatabase.h:18
void Run()
Run OPAL algorithm.
Definition: OPAL.cpp:228
Header file with definition of SSD class.
void ConstrainedInitialization()
Constraint initialization.
Definition: OPAL.cpp:45
SegType GetOutput() const
Definition: OPAL.h:66
Class implementing the core of OPAL algorithm.
Definition: OPAL.h:34
const Image< int > & getFieldX() const
Definition: OPAL.h:77
const Image< SSDType > & getSSDMap() const
Definition: OPAL.h:86
Definition: Image.h:11
Header with declaration of OPALSettings class.
OPAL(const OPALSettings &settings, const DatabaseType &database)
Definition: OPAL.cpp:16
Class responsible for SSD calculation between patches of images.
Definition: SSD.h:31
A lightweight class containing various OPAL options.
Definition: OPALSettings.h:21
const Image< int > & getFieldY() const
Definition: OPAL.h:80