Ocean
SynthesisPyramidI1.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_CV_SYNTHESIS_SYNTHESIS_PYRAMID_I_1_H
9 #define META_OCEAN_CV_SYNTHESIS_SYNTHESIS_PYRAMID_I_1_H
10 
15 
17 
18 namespace Ocean
19 {
20 
21 namespace CV
22 {
23 
24 namespace Synthesis
25 {
26 
27 /**
28  * This class implements the main pixel synthesis object holding several synthesis pyramid layers for one-frame synthesis.
29  * @ingroup cvsynthesis
30  */
31 class OCEAN_CV_SYNTHESIS_EXPORT SynthesisPyramidI1 : public SynthesisPyramid
32 {
33  public:
34 
35  // We want to use all implementations in this class.
37 
38  public:
39 
40  /**
41  * Creates a new synthesis pyramid object.
42  * Each synthesis pyramid must be arranged before an inpainting strategy can be invoked.
43  * @see arrange().
44  */
45  inline SynthesisPyramidI1();
46 
47  /**
48  * Returns the finest synthesis layer of this pyramid object.
49  * Beware: Ensure that this pyramid holds at least one layer before calling this function!
50  * @return The pyramid's finest synthesis layer
51  */
52  inline const LayerI1& finestLayer() const;
53 
54  /**
55  * Returns the finest synthesis layer of this pyramid object.
56  * Beware: Ensure that this pyramid holds at least one layer before calling this function!
57  * @return The pyramid's finest synthesis layer
58  */
59  inline LayerI1& finestLayer();
60 
61  /**
62  * Returns the number of layers of this pyramid.
63  * @return The pyramid's number of layers, with range [0, infinity)
64  */
65  inline size_t layers() const;
66 
67  /**
68  * Applies the inpainting on an initialized synthesis pyramid while a specific initialization technique is used on the coarsest pyramid layer.
69  * @see SynthesisPyramid::applyInpainting().
70  */
71  bool applyInpainting(const InitializationTechnique initializationTechnique, RandomGenerator& randomGenerator, const unsigned int weightFactor = 5u, const unsigned int borderFactor = 26u, const unsigned int maxSpatialCost = (unsigned int)(-1), const unsigned int optimizationIterations = 2u, const unsigned int forced1ChannelLayers = 0u, const unsigned int skippingLayers = 0u, Worker* worker = nullptr) override;
72 
73  /**
74  * Applies the inpainting on an initialized synthesis pyramid while using a set of constraints to guide the inpainting result and quality.
75  * @param constraints The constraints to be used to guide the inpainting, at least one
76  * @param randomGenerator The random number generator to be used
77  * @param weightFactor Spatial weight impact, with range [0, infinity)
78  * @param borderFactor Weight factor of border pixels, with range [1, infinity)
79  * @param maxSpatialCost Maximal spatial cost, with range [0, 0xFFFFFFFF]
80  * @param optimizationIterations The number of optimization iterations on each pyramid layer (but on the coarsest layer), with range [1, infinity)
81  * @param skippingConstraintLayers The number of (finest) layers on which the constraints will not be applied anymore, with range [0, infinity)
82  * @param worker Optional worker object to distribute the computation
83  * @return True, if succeeded
84  */
85  bool applyInpainting(const Constraints& constraints, RandomGenerator& randomGenerator, const unsigned int weightFactor = 5u, const unsigned int borderFactor = 26u, const unsigned int maxSpatialCost = (unsigned int)(-1), const unsigned int optimizationIterations = 4u, const unsigned int skippingConstraintLayers = 2u, Worker* worker = nullptr);
86 
87  /**
88  * Creates the final inpainting result for the finest pyramid layer.
89  * @see SynthesisPyramid::createInpaintingResult().
90  */
91  bool createInpaintingResult(Frame& frame, Worker* worker = nullptr) const override;
92 
93  /**
94  * Returns whether this pyramid object holds at least one layer.
95  * @return True, if so
96  */
97  explicit inline operator bool() const;
98 
99  private:
100 
101  /// The individual synthesis layers for individual frame resolutions with reversed layer order.
103 };
104 
107 {
108  // nothing to do here
109 }
110 
112 {
113  ocean_assert(!layersReversedOrder_.empty());
114  return layersReversedOrder_.back();
115 }
116 
118 {
119  ocean_assert(!layersReversedOrder_.empty());
120  return layersReversedOrder_.back();
121 }
122 
123 inline size_t SynthesisPyramidI1::layers() const
124 {
125  return layersReversedOrder_.size();
126 }
127 
128 inline SynthesisPyramidI1::operator bool() const
129 {
130  return !layersReversedOrder_.empty();
131 }
132 
133 }
134 
135 }
136 
137 }
138 
139 #endif // META_OCEAN_CV_SYNTHESIS_SYNTHESIS_PYRAMID_I_1_H
This class implements a container holding constraints.
Definition: Constraint.h:304
This class implements a single layer for pixel synthesis within one frame and pixel accuracy.
Definition: LayerI1.h:41
This class implements the base class for all synthesis pyramids.
Definition: SynthesisPyramid.h:33
virtual bool applyInpainting(const SynthesisQuality synthesisQuality, RandomGenerator &randomGenerator, const unsigned int weightFactor=5u, const unsigned int borderFactor=25u, const unsigned int maxSpatialCost=(unsigned int)(-1), Worker *worker=nullptr)
Applies the inpainting on an initialized synthesis pyramid satisfying a specific quality.
InitializationTechnique
Definition of individual initialization techniques.
Definition: SynthesisPyramid.h:55
This class implements the main pixel synthesis object holding several synthesis pyramid layers for on...
Definition: SynthesisPyramidI1.h:32
size_t layers() const
Returns the number of layers of this pyramid.
Definition: SynthesisPyramidI1.h:123
const LayerI1 & finestLayer() const
Returns the finest synthesis layer of this pyramid object.
Definition: SynthesisPyramidI1.h:111
SynthesisPyramidI1()
Creates a new synthesis pyramid object.
Definition: SynthesisPyramidI1.h:105
LayersI1 layersReversedOrder_
The individual synthesis layers for individual frame resolutions with reversed layer order.
Definition: SynthesisPyramidI1.h:102
bool applyInpainting(const Constraints &constraints, RandomGenerator &randomGenerator, const unsigned int weightFactor=5u, const unsigned int borderFactor=26u, const unsigned int maxSpatialCost=(unsigned int)(-1), const unsigned int optimizationIterations=4u, const unsigned int skippingConstraintLayers=2u, Worker *worker=nullptr)
Applies the inpainting on an initialized synthesis pyramid while using a set of constraints to guide ...
bool createInpaintingResult(Frame &frame, Worker *worker=nullptr) const override
Creates the final inpainting result for the finest pyramid layer.
bool applyInpainting(const InitializationTechnique initializationTechnique, RandomGenerator &randomGenerator, const unsigned int weightFactor=5u, const unsigned int borderFactor=26u, const unsigned int maxSpatialCost=(unsigned int)(-1), const unsigned int optimizationIterations=2u, const unsigned int forced1ChannelLayers=0u, const unsigned int skippingLayers=0u, Worker *worker=nullptr) override
Applies the inpainting on an initialized synthesis pyramid while a specific initialization technique ...
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
std::vector< LayerI1 > LayersI1
Definition of a vector holding one-frame pixel layer objects.
Definition: LayerI1.h:27
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15