8#ifndef META_OCEAN_CV_SYNTHESIS_CREATOR_INFORMATION_COST_4_NEIGHBORHOOD_I_1_H
9#define META_OCEAN_CV_SYNTHESIS_CREATOR_INFORMATION_COST_4_NEIGHBORHOOD_I_1_H
31template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
42 using Costs = std::vector<uint64_t>;
66 void createSubset(
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 createSubsetChannels(
const unsigned int firstColumn,
const unsigned int numberColumns,
const unsigned int firstRow,
const unsigned int numberRows)
const;
94template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
107template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
118 const size_t firstRow =
layerI1_.boundingBox() ?
layerI1_.boundingBox().top() : 0u;
123 for (
size_t n = 0; n < firstRow; ++n)
127 for (
size_t n = endRow; n <
layerI1_.height(); ++n)
134 for (
size_t n = firstRow; n < endRow; ++n)
142template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
145 ocean_assert(
layerI1_.frame().numberPlanes() == 1u);
147 switch (
layerI1_.frame().channels())
166 ocean_assert(
false &&
"Invalid frame type.");
170template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
171template <
unsigned int tChannels>
174 const uint8_t* layerFrame =
layerI1_.frame().template constdata<uint8_t>();
175 const uint8_t* layerMask =
layerI1_.mask().template constdata<uint8_t>();
177 const unsigned int layerFramePaddingElements =
layerI1_.frame().paddingElements();
178 const unsigned int layerMaskPaddingElements =
layerI1_.mask().paddingElements();
184 ocean_assert(!debugLayerBoundingBox || firstRow >= debugLayerBoundingBox.
top());
185 ocean_assert(!debugLayerBoundingBox || firstRow + numberRows <= debugLayerBoundingBox.
bottomEnd());
190 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
194 const uint8_t* maskRow =
layerI1_.mask().template constrow<uint8_t>(y);
197 for (
unsigned int x = firstColumn; x < firstColumn + numberColumns; ++x)
199 if (maskRow[x] != 0xFFu)
204 const unsigned int appearanceCost = layerMapping.
appearanceCost5x5<tChannels, tBorderFactor>(x, y, mapping.
x(), mapping.
y(), layerFrame, layerMask, layerFramePaddingElements, layerMaskPaddingElements);
206 rowCost += uint64_t(tWeightFactor) * uint64_t(spatialCost) + uint64_t(appearanceCost);
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
T y() const
Returns the vertical coordinate position of this object.
Definition PixelPosition.h:468
T x() const
Returns the horizontal coordinate position of this object.
Definition PixelPosition.h:456
Creator1(const Layer &layer)
Creates a new creator object.
Definition Creator1.h:38
This class implements the base class for all creators.
Definition Creator.h:29
const LayerI & layerI_
Specialized layer reference.
Definition CreatorI.h:41
CreatorI(const LayerI &layer)
Creates a new creator object.
Definition CreatorI.h:44
bool invoke(Worker *worker=nullptr) const override
Invokes the creator.
CreatorSubset(const Layer &layer)
Creates a new creator object.
Definition CreatorSubset.h:55
This class implements a single layer for pixel synthesis within one frame and pixel accuracy.
Definition LayerI1.h:41
This class implements the pixel mapping between source and target frames.
Definition MappingI1.h:49
unsigned int spatialCost4Neighborhood(const unsigned int xTarget, const unsigned int yTarget, const unsigned int xSource, const unsigned int ySource, const uint8_t *targetMask, const unsigned int targetMaskPaddingElements, const unsigned int maxCost) const
Calculates the smallest/cheapest spatial cost for a given point in a four-neighborhood and normalizes...
Definition MappingI1.h:212
unsigned int appearanceCost5x5(const unsigned int xTarget, const unsigned int yTarget, const unsigned int xSource, const unsigned int ySource, const uint8_t *frame, const uint8_t *mask, const unsigned int framePaddingElements, const unsigned int maskPaddingElements) const
Calculates the appearance cost for a given point in a given frame.
Definition MappingI1.h:666
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
PixelPositionT< unsigned int > PixelPosition
Definition of the default PixelPosition object with a data type allowing only positive coordinate val...
Definition PixelPosition.h:32
PixelBoundingBoxT< unsigned int > PixelBoundingBox
Definition of the default PixelBoundingBox object with data type allowing only positive coordinate va...
Definition PixelBoundingBox.h:28
Namespace of the CV Synthesis library.
Definition Constraint.h:25
Namespace of the CV library.
Definition Advanced.h:17
The namespace covering the entire Ocean framework.
Definition Accessor.h:15