8 #ifndef META_OCEAN_CV_SYNTHESIS_INITIALIZER_COARSER_MAPPING_ADAPTION_I_1_H
9 #define META_OCEAN_CV_SYNTHESIS_INITIALIZER_COARSER_MAPPING_ADAPTION_I_1_H
34 template <
unsigned int tFactor>
57 void initializeSubset(
const unsigned int firstColumn,
const unsigned int numberColumns,
const unsigned int firstRow,
const unsigned int numberRows)
const override;
65 template <
unsigned int tFactor>
72 coarserLayerI_(coarserLayer)
77 template <
unsigned int tFactor>
80 static_assert(tFactor >= 2u,
"Invalid factor!");
82 const unsigned int width = layerI_.width();
83 const unsigned int height = layerI_.height();
85 const unsigned int coarserWidth = coarserLayerI_.width();
86 const unsigned int coarserHeight = coarserLayerI_.height();
88 ocean_assert(width / tFactor == coarserWidth);
89 ocean_assert(height / tFactor == coarserHeight);
91 MappingI& mapping = layerI_.mapping();
92 const MappingI& coarserMapping = coarserLayerI_.mapping();
96 const uint8_t*
const mask = layerI_.mask().template constdata<uint8_t>();
97 const uint8_t*
const coarserMask = coarserLayerI_.mask().template constdata<uint8_t>();
99 const unsigned int maskStrideElements = layerI_.mask().strideElements();
100 const unsigned int coarserMaskStrideElements = coarserLayerI_.mask().strideElements();
102 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
104 const uint8_t* maskRow = mask + y * maskStrideElements;
107 const unsigned int yCoarser = min(y / tFactor, coarserHeight - 1u);
109 const uint8_t* coarserMaskRow = coarserMask + yCoarser * coarserMaskStrideElements;
112 for (
unsigned int x = firstColumn; x < firstColumn + numberColumns; ++x)
114 if (maskRow[x] != 0xFFu)
116 const unsigned int xCoarser = min(x / tFactor, coarserWidth - 1u);
119 if (coarserMaskRow[xCoarser] != 0xFFu)
121 const PixelPosition& coarserPosition = coarserPositionRow[xCoarser];
122 ocean_assert(coarserPosition.
x() < coarserLayerI_.width());
123 ocean_assert(coarserPosition.
y() < coarserLayerI_.height());
125 const unsigned int candidateX = (
unsigned int)(
int(x) + (int(coarserPosition.
x()) - int(xCoarser)) *
int(tFactor));
126 const unsigned int candidateY = (
unsigned int)(
int(y) + (int(coarserPosition.
y()) - int(yCoarser)) *
int(tFactor));
128 ocean_assert(candidateX < width);
129 ocean_assert(candidateY < height);
131 if (mask[candidateY * maskStrideElements + candidateX] == 0xFFu)
138 unsigned int candidateX, candidateY;
144 while (mask[candidateY * maskStrideElements + candidateX] != 0xFFu);
T y() const
Returns the vertical coordinate position of this object.
Definition: PixelPosition.h:470
T x() const
Returns the horizontal coordinate position of this object.
Definition: PixelPosition.h:458
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: InitializerCoarserMappingAdaptionI1.h:40
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: InitializerCoarserMappingAdaptionI1.h:78
InitializerCoarserMappingAdaptionI1(LayerI1 &layer, RandomGenerator &randomGenerator, const LayerI1 &coarserLayer)
Creates a new initializer object.
Definition: InitializerCoarserMappingAdaptionI1.h:66
const LayerI1 & coarserLayerI_
Coarser synthesis layer from that the mapping will be adapted.
Definition: InitializerCoarserMappingAdaptionI1.h:62
This class implements the base class for all synthesis initializers.
Definition: Initializer.h:34
This class implements the base class for all initializer objects that are applied for mappings with i...
Definition: InitializerI.h:30
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 pixel accuracy.
Definition: LayerI1.h:41
This class implements a mapping with integer accuracy.
Definition: MappingI.h:30
const PixelPosition * row(const unsigned int y) const
Returns the pointer to a mapping row.
Definition: MappingI.h:243
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
static unsigned int random(const unsigned int maxValue)
Returns one random integer value with specified maximum value.
PixelPositionT< unsigned int > PixelPosition
Definition of the default PixelPosition object with a data type allowing only positive coordinate val...
Definition: PixelPosition.h:27
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15