Ocean
OptimizerI.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_OPTIMIZER_I_H
9 #define META_OCEAN_CV_SYNTHESIS_OPTIMIZER_I_H
10 
14 
15 namespace Ocean
16 {
17 
18 namespace CV
19 {
20 
21 namespace Synthesis
22 {
23 
24 /**
25  * This class is the base class for all optimizers that use a mapping with integer accuracy.
26  * @ingroup cvsynthesis
27  */
28 class OCEAN_CV_SYNTHESIS_EXPORT OptimizerI : virtual public Optimizer
29 {
30  public:
31 
32  /**
33  * Calculate the search radii for the mapping optimization.
34  * @param radii Number of radii to create, with range [1, infinity)
35  * @param width The width of the frame in pixel, with range [1, infinity)
36  * @param height The height of the frame in pixel, with range [1, infinity)
37  * @return Resulting search radii
38  */
39  static inline std::vector<int> calculateSearchRadii(const unsigned int radii, const unsigned int width, const unsigned int height);
40 
41  protected:
42 
43  /**
44  * Creates a new optimizer object.
45  * @param layer Synthesis layer that will be optimized
46  */
47  inline OptimizerI(LayerI& layer);
48 
49  private:
50 
51  /// Specialized layer reference.
53 };
54 
56  Operator(),
57  Optimizer(layer),
58  layerI_(layer)
59 {
60  OCEAN_SUPPRESS_UNUSED_WARNING(layerI_);
61 }
62 
63 inline std::vector<int> OptimizerI::calculateSearchRadii(const unsigned int radii, const unsigned int width, const unsigned int height)
64 {
65  ocean_assert(radii != 0u);
66  ocean_assert(width != 0u && height != 0u);
67 
68  std::vector<int> result(radii);
69 
70  const unsigned int maxWidthHeight = max(width, height);
71 
72  for (unsigned int n = 0u; n < radii; ++n)
73  {
74  result[n] = int(max(2u, (maxWidthHeight - (maxWidthHeight - 1u) * n / radii + 1u) / 2u));
75  }
76 
77  return result;
78 }
79 
80 }
81 
82 }
83 
84 }
85 
86 #endif // META_OCEAN_CV_SYNTHESIS_OPTIMIZER_I_H
This class implements the base class for all synthesis layers with integer accuracy.
Definition: LayerI.h:29
This class is the base class for all image synthesis operators.
Definition: Operator.h:28
This class is the base class for all synthesis optimizers.
Definition: Optimizer.h:30
This class is the base class for all optimizers that use a mapping with integer accuracy.
Definition: OptimizerI.h:29
static std::vector< int > calculateSearchRadii(const unsigned int radii, const unsigned int width, const unsigned int height)
Calculate the search radii for the mapping optimization.
Definition: OptimizerI.h:63
LayerI & layerI_
Specialized layer reference.
Definition: OptimizerI.h:52
OptimizerI(LayerI &layer)
Creates a new optimizer object.
Definition: OptimizerI.h:55
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15