8 #ifndef META_OCEAN_CV_SYNTHESIS_INITIALIZER_COARSER_MAPPING_ADAPTION_F_1_H
9 #define META_OCEAN_CV_SYNTHESIS_INITIALIZER_COARSER_MAPPING_ADAPTION_F_1_H
34 template <
unsigned int tFactor>
58 void initializeSubset(
const unsigned int firstColumn,
const unsigned int numberColumns,
const unsigned int firstRow,
const unsigned int numberRows)
const override;
66 template <
unsigned int tFactor>
73 coarserLayerF_(coarserLayer)
78 template <
unsigned int tFactor>
81 static_assert(tFactor >= 2u,
"Invalid factor!");
83 const unsigned int width = layerF_.width();
84 const unsigned int height = layerF_.height();
86 const unsigned int coarserWidth = coarserLayerF_.width();
87 const unsigned int coarserHeight = coarserLayerF_.height();
89 ocean_assert(width / tFactor == coarserWidth);
90 ocean_assert(height / tFactor == coarserHeight);
92 MappingF& mapping = layerF_.mapping();
93 const MappingF& coarserMapping = coarserLayerF_.mapping();
97 const uint8_t*
const mask = layerF_.mask().template constdata<uint8_t>();
98 const uint8_t*
const coarserMask = coarserLayerF_.mask().template constdata<uint8_t>();
100 const unsigned int maskStrideElements = layerF_.mask().strideElements();
101 const unsigned int coarserMaskStrideElements = coarserLayerF_.mask().strideElements();
103 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
105 const uint8_t* maskRow = mask + y * maskStrideElements;
108 const unsigned int yCoarser = min(y / tFactor, coarserHeight - 1u);
110 const uint8_t* coarserMaskRow = coarserMask + yCoarser * coarserMaskStrideElements;
111 const Vector2* coarserPositionRow = coarserMapping.
row(yCoarser);
113 for (
unsigned int x = firstColumn; x < firstColumn + numberColumns; ++x)
115 if (maskRow[x] != 0xFFu)
117 const unsigned int xCoarser = min(x / tFactor, coarserWidth - 1u);
120 if (coarserMaskRow[xCoarser] != 0xFFu)
122 const Vector2& coarserPosition = coarserPositionRow[xCoarser];
123 ocean_assert(coarserPosition.
x() <
Scalar(coarserLayerF_.width()));
124 ocean_assert(coarserPosition.
y() <
Scalar(coarserLayerF_.height()));
129 const unsigned int intCandidateX = (
unsigned int)(
Numeric::round32(candidateX));
130 const unsigned int intCandidateY = (
unsigned int)(
Numeric::round32(candidateY));
132 if (mask[intCandidateY * maskStrideElements + intCandidateX] == 0xFFu)
134 positionRow[x] =
Vector2(candidateX, candidateY);
145 const unsigned int intCandidateX = (
unsigned int)(
Numeric::round32(candidate.
x()));
146 const unsigned int intCandidateY = (
unsigned int)(
Numeric::round32(candidate.
y()));
148 if (mask[intCandidateY * maskStrideElements + intCandidateX] == 0xFFu)
150 positionRow[x] = candidate;
This class is the base class for all initializers that are provided for a single frame only.
Definition: Initializer1.h:29
This initializer creates an initial mapping by the adaption of an already existing mapping of a coars...
Definition: InitializerCoarserMappingAdaptionF1.h:40
const LayerF1 & coarserLayerF_
Coarser layer that has to be adopted.
Definition: InitializerCoarserMappingAdaptionF1.h:63
void initializeSubset(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const override
Initializes a subset of the entire mapping area.
Definition: InitializerCoarserMappingAdaptionF1.h:79
InitializerCoarserMappingAdaptionF1(LayerF1 &layer, RandomGenerator &randomGenerator, const LayerF1 &coarserLayer)
Creates a new initializer object.
Definition: InitializerCoarserMappingAdaptionF1.h:67
This class implements the base class for all initializer objects that are applied for mappings with f...
Definition: InitializerF.h:30
This class implements the base class for all synthesis initializers.
Definition: Initializer.h:34
This class is the base class for all initializers that mainly initialize the synthesis mapping by a h...
Definition: InitializerRandomized.h:30
This class is the base class for all initializer objects that can separate the initialization process...
Definition: InitializerSubset.h:29
This class implements a single layer for pixel synthesis within one frame and sub-pixel accuracy.
Definition: LayerF1.h:44
This class implements a mapping with float accuracy.
Definition: MappingF.h:30
const Vector2 * row(const unsigned int y) const
Returns the pointer to a mapping row.
Definition: MappingF.h:210
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition: Numeric.h:2064
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
static VectorT2< T > vector2()
Returns a random 2D vector with length 1 which is equal distributed within a circle.
Definition: Random.h:472
const T & x() const noexcept
Returns the x value.
Definition: Vector2.h:698
const T & y() const noexcept
Returns the y value.
Definition: Vector2.h:710
float Scalar
Definition of a scalar type.
Definition: Math.h:128
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15