Ocean
Loading...
Searching...
No Matches
OptimizerF.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_F_H
9#define META_OCEAN_CV_SYNTHESIS_OPTIMIZER_F_H
10
14
15namespace Ocean
16{
17
18namespace CV
19{
20
21namespace Synthesis
22{
23
24/**
25 * This class is the base class for all optimizers that use a mapping with float accuracy.
26 * @ingroup cvsynthesis
27 */
28class OCEAN_CV_SYNTHESIS_EXPORT OptimizerF : virtual public Optimizer
29{
30 public:
31
32 /**
33 * Calculates 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<Scalar> 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 The layer that has to be optimized
46 */
47 inline OptimizerF(LayerF& layer);
48
49 private:
50
51 /// Specialized layer reference.
53};
54
56 Operator(),
57 Optimizer(layer),
58 layerF_(layer)
59{
60 OCEAN_SUPPRESS_UNUSED_WARNING(layerF_);
61}
62
63inline std::vector<Scalar> OptimizerF::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<Scalar> result(radii);
69
70 const Scalar maxWidthHeight = Scalar(max(width, height));
71
72 for (unsigned int n = 0; n < radii; ++n)
73 {
74 result[n] = max(Scalar(2), Scalar(Scalar(maxWidthHeight) - Scalar(maxWidthHeight - 1u) * Scalar(n) / Scalar(radii)) * Scalar(0.5));
75 }
76
77 return result;
78}
79
80}
81
82}
83
84}
85
86#endif // META_OCEAN_CV_SYNTHESIS_OPTIMIZER_F_H
This class implements the base class for all synthesis layers with float accuracy.
Definition LayerF.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 optimizers that use a mapping with float accuracy.
Definition OptimizerF.h:29
LayerF & layerF_
Specialized layer reference.
Definition OptimizerF.h:52
OptimizerF(LayerF &layer)
Creates a new optimizer object.
Definition OptimizerF.h:55
static std::vector< Scalar > calculateSearchRadii(const unsigned int radii, const unsigned int width, const unsigned int height)
Calculates the search radii for the mapping optimization.
Definition OptimizerF.h:63
This class is the base class for all synthesis optimizers.
Definition Optimizer.h:30
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15