8#ifndef META_OCEAN_CV_SYNTHESIS_INITIALIZER_APPEARANCE_MAPPING_F_1_H 
    9#define META_OCEAN_CV_SYNTHESIS_INITIALIZER_APPEARANCE_MAPPING_F_1_H 
   41template <
unsigned int tPatchSize, 
unsigned int tIterations>
 
   65        void initializeSubset(
const unsigned int firstColumn, 
const unsigned int numberColumns, 
const unsigned int firstRow, 
const unsigned int numberRows) 
const override;
 
   76        template <
unsigned int tChannels>
 
   77        void initializeSubsetChannels(
const unsigned int firstColumn, 
const unsigned int numberColumns, 
const unsigned int firstRow, 
const unsigned int numberRows) 
const;
 
 
   80template <
unsigned int tPatchSize, 
unsigned int tIterations>
 
   92template <
unsigned int tPatchSize, 
unsigned int tIterations>
 
   95    static_assert(tPatchSize == 1u, 
"Invalid patch size!");
 
   97    ocean_assert(layerF_.frame().numberPlanes() == 1u);
 
  100    switch (layerF_.frame().channels())
 
  103            initializeSubsetChannels<1u>(firstColumn, numberColumns, firstRow, numberRows);
 
  107            initializeSubsetChannels<2u>(firstColumn, numberColumns, firstRow, numberRows);
 
  111            initializeSubsetChannels<3u>(firstColumn, numberColumns, firstRow, numberRows);
 
  115            initializeSubsetChannels<4u>(firstColumn, numberColumns, firstRow, numberRows);
 
  119            ocean_assert(
false && 
"Invalid frame type.");
 
 
  123template <
unsigned int tPatchSize, 
unsigned int tIterations>
 
  124template <
unsigned int tChannels>
 
  127    static_assert(tPatchSize == 1, 
"Missing Implementation: Currently tPatchSize must be 1");
 
  128    static_assert(tChannels >= 1u, 
"Invalid channel number!");
 
  130    const unsigned int tPatchSize_2 = tPatchSize / 2u;
 
  132    const unsigned int width = layerF_.width();
 
  133    const unsigned int height = layerF_.height();
 
  135    MappingF& layerMapping = layerF_.mapping();
 
  137    const Frame& frame = layerF_.frame();
 
  138    const Frame& mask = layerF_.mask();
 
  143    ocean_assert(frame.
width() == width);
 
  144    ocean_assert(frame.
height() == height);
 
  150    const uint8_t* 
const frameData = frame.
constdata<uint8_t>();
 
  151    const uint8_t* 
const maskData = mask.
constdata<uint8_t>();
 
  158    ocean_assert(!debugLayerBoundingBox || firstColumn >= debugLayerBoundingBox.
left());
 
  159    ocean_assert(!debugLayerBoundingBox || firstColumn + numberColumns <= debugLayerBoundingBox.
rightEnd());
 
  160    ocean_assert(!debugLayerBoundingBox || firstRow >= debugLayerBoundingBox.
top());
 
  161    ocean_assert(!debugLayerBoundingBox || firstRow + numberRows <= debugLayerBoundingBox.
bottomEnd());
 
  164    ocean_assert(firstColumn + numberColumns <= width);
 
  165    ocean_assert(firstRow + numberRows <= height);
 
  170    for (
unsigned int y = firstRow; y < std::min(firstRow + numberRows, height - 1u); ++y)
 
  172        const uint8_t* maskRow = maskData + y * maskStrideElements + firstColumn;
 
  173        Vector2* position = layerMapping.
row(y) + firstColumn;
 
  175        for (
unsigned int x = firstColumn; x < std::min(firstColumn + numberColumns, width - 1u); ++x)
 
  177            if (*maskRow++ != 0xFFu)
 
  188                unsigned int bestSSD = Advanced::AdvancedSumSquareDifferences::patch8BitPerChannel<tChannels, tPatchSize>(frameData, frameData, width, width, 
Scalar(x), 
Scalar(y), bestX, bestY, framePaddingElements, framePaddingElements)
 
  191                for (
unsigned int n = 1u; n < tIterations; ++n)
 
  201                    const unsigned int candidateSSD = Advanced::AdvancedSumSquareDifferences::patch8BitPerChannel<tChannels, tPatchSize>(frameData, frameData, width, width, 
Scalar(x), 
Scalar(y), candidateX, candidateY, framePaddingElements, framePaddingElements)
 
  204                    if (candidateSSD < bestSSD)
 
  208                        bestSSD = candidateSSD;
 
  212                *position = 
Vector2(bestX, bestY);
 
 
T left() const
Returns the left (including) pixel position of this bounding box.
Definition PixelBoundingBox.h:416
 
T rightEnd() const
Returns the right (excluding) pixel position of this bounding box.
Definition PixelBoundingBox.h:437
 
T bottomEnd() const
Returns the bottom (excluding) pixel position of this bounding box.
Definition PixelBoundingBox.h:451
 
T top() const
Returns the top (including) pixel position of this bounding box.
Definition PixelBoundingBox.h:423
 
This class is the base class for all initializers that are provided for a single frame only.
Definition Initializer1.h:29
 
This class implements an initializer that initializes the mapping by appearance constraints for mappi...
Definition InitializerAppearanceMappingF1.h:48
 
InitializerAppearanceMappingF1(LayerF1 &layer, RandomGenerator &randomGenerator)
Creates a new initializer object.
Definition InitializerAppearanceMappingF1.h:81
 
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 InitializerAppearanceMappingF1.h:93
 
void initializeSubsetChannels(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const
This function is the specialization of the default initializeSubset() function.
Definition InitializerAppearanceMappingF1.h:125
 
This class implements the abstract base class for all appearance initializers.
Definition InitializerAppearanceMapping.h:28
 
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
 
This class implements Ocean's image class.
Definition Frame.h:1808
 
unsigned int strideElements(const unsigned int planeIndex=0u) const
Returns the number of elements within one row, including optional padding at the end of a row for a s...
Definition Frame.h:4141
 
const T * constdata(const unsigned int planeIndex=0u) const
Returns a pointer to the read-only pixel data of a specific plane.
Definition Frame.h:4251
 
bool isValid() const
Returns whether this frame is valid.
Definition Frame.h:4531
 
unsigned int paddingElements(const unsigned int planeIndex=0u) const
Returns the optional number of padding elements at the end of each row for a specific plane.
Definition Frame.h:4125
 
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
 
unsigned int width() const
Returns the width of the frame format in pixel.
Definition Frame.h:3170
 
uint32_t numberPlanes() const
Returns the number of planes of the pixel format of this frame.
Definition Frame.h:3210
 
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition Frame.h:3180
 
@ DT_UNSIGNED_INTEGER_8
Unsigned 8 bit integer data type (uint8_t).
Definition Frame.h:41
 
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3175
 
DataType dataType() const
Returns the data type of the pixel format of this frame.
Definition Frame.h:3190
 
bool isFrameTypeCompatible(const FrameType &frameType, const bool allowDifferentPixelOrigins) const
Returns whether this frame type is compatible with a given frame type.
Definition Frame.h:3232
 
static constexpr T weakEps()
Returns a weak epsilon.
 
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition Numeric.h:2067
 
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
 
static T scalar(const T lower, const T upper)
Returns a random number between two borders.
Definition Random.h:388
 
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition base/Utilities.h:1113
 
float Scalar
Definition of a scalar type.
Definition Math.h:129
 
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
 
The namespace covering the entire Ocean framework.
Definition Accessor.h:15