8 #ifndef META_OCEAN_CV_SYNTHESIS_INITIALIZER_COARSER_MAPPING_ADAPTION_AREA_CONSTRAINED_I_1_H
9 #define META_OCEAN_CV_SYNTHESIS_INITIALIZER_COARSER_MAPPING_ADAPTION_AREA_CONSTRAINED_I_1_H
36 template <
unsigned int tFactor>
63 void initializeSubset(
const unsigned int firstColumn,
const unsigned int numberColumns,
const unsigned int firstRow,
const unsigned int numberRows)
const override;
71 template <
unsigned int tFactor>
79 coarserLayerI_(coarserLayer)
84 template <
unsigned int tFactor>
87 static_assert(tFactor >= 2u,
"Invalid factor!");
89 const unsigned int width = layerI_.width();
90 const unsigned int height = layerI_.height();
92 const unsigned int coarserWidth = coarserLayerI_.width();
93 const unsigned int coarserHeight = coarserLayerI_.height();
95 ocean_assert(width / tFactor == coarserWidth);
96 ocean_assert(height / tFactor == coarserHeight);
98 MappingI& mapping = layerI_.mapping();
99 const MappingI& coarserMapping = coarserLayerI_.mapping();
103 const uint8_t*
const maskData = layerI_.mask().template constdata<uint8_t>();
104 const uint8_t*
const filterData = filter_.constdata<uint8_t>();
105 const uint8_t*
const coarserMaskData = coarserLayerI_.mask().template constdata<uint8_t>();
107 const unsigned int maskStrideElements = layerI_.mask().strideElements();
108 const unsigned int filterStrideElements = filter_.strideElements();
109 const unsigned int coarserMaskStrideElements = coarserLayerI_.mask().strideElements();
111 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
113 const uint8_t* maskRow = maskData + y * maskStrideElements;
116 const unsigned int yCoarser = min(y / tFactor, coarserHeight - 1u);
118 const uint8_t* coarserMaskRow = coarserMaskData + yCoarser * coarserMaskStrideElements;
121 for (
unsigned int x = firstColumn; x < firstColumn + numberColumns; ++x)
123 if (maskRow[x] != 0xFFu)
125 const unsigned int xCoarser = min(x / tFactor, coarserWidth - 1u);
128 if (coarserMaskRow[xCoarser] != 0xFFu)
130 const PixelPosition& coarserPosition = coarserPositionRow[xCoarser];
131 ocean_assert(coarserPosition.
x() < coarserLayerI_.width());
132 ocean_assert(coarserPosition.
y() < coarserLayerI_.height());
134 const unsigned int candidateX = (
unsigned int)(
int(x) + (int(coarserPosition.
x()) - int(xCoarser)) *
int(tFactor));
135 const unsigned int candidateY = (
unsigned int)(
int(y) + (int(coarserPosition.
y()) - int(yCoarser)) *
int(tFactor));
137 ocean_assert(candidateX < width);
138 ocean_assert(candidateY < height);
140 if (maskData[candidateY * maskStrideElements + candidateX] == 0xFFu && filterData[candidateY * filterStrideElements + candidateX] == 0xFFu)
147 unsigned int candidateX, candidateY;
153 while (maskData[candidateY * maskStrideElements + candidateX] != 0xFFu || filterData[candidateY * filterStrideElements + 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 class implements a base class for all initializers basing on area constraints.
Definition: InitializerAreaConstrained.h:30
This initializer creates an initial mapping by the adaption of an already existing mapping of a coars...
Definition: InitializerCoarserMappingAdaptionAreaConstrainedI1.h:43
InitializerCoarserMappingAdaptionAreaConstrainedI1(LayerI1 &layer, RandomGenerator &randomGenerator, const LayerI1 &coarserLayer, const Frame &filter)
Creates a new initializer object.
Definition: InitializerCoarserMappingAdaptionAreaConstrainedI1.h:72
const LayerI1 & coarserLayerI_
Coarser synthesis layer to be used for the mapping adoption.
Definition: InitializerCoarserMappingAdaptionAreaConstrainedI1.h:68
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: InitializerCoarserMappingAdaptionAreaConstrainedI1.h:85
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 Ocean's image class.
Definition: Frame.h:1792
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