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
31 template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
42 typedef std::vector<uint64_t>
Costs;
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;
94 template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
102 maxSpatialCost_(maxSpatialCost)
107 template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
110 rowCost_ =
Costs(layerI1_.height(), 0u);
118 const size_t firstRow = layerI1_.boundingBox() ? layerI1_.boundingBox().top() : 0u;
119 const size_t endRow = layerI1_.boundingBox() ? layerI1_.boundingBox().bottomEnd() : layerI1_.height();
123 for (
size_t n = 0; n < firstRow; ++n)
125 ocean_assert(rowCost_[n] == 0);
127 for (
size_t n = endRow; n < layerI1_.height(); ++n)
129 ocean_assert(rowCost_[n] == 0);
134 for (
size_t n = firstRow; n < endRow; ++n)
136 cost_ += rowCost_[n];
142 template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
145 ocean_assert(layerI1_.frame().numberPlanes() == 1u);
147 switch (layerI1_.frame().channels())
150 createSubsetChannels<1u>(firstColumn, numberColumns, firstRow, numberRows);
154 createSubsetChannels<2u>(firstColumn, numberColumns, firstRow, numberRows);
158 createSubsetChannels<3u>(firstColumn, numberColumns, firstRow, numberRows);
162 createSubsetChannels<4u>(firstColumn, numberColumns, firstRow, numberRows);
166 ocean_assert(
false &&
"Invalid frame type.");
170 template <
unsigned int tWeightFactor,
unsigned int tBorderFactor>
171 template <
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();
180 const MappingI1& layerMapping = layerI1_.mapping();
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)
203 const unsigned int spatialCost = layerMapping.
spatialCost4Neighborhood<tChannels>(x, y, mapping.
x(), mapping.
y(), layerMask, layerMaskPaddingElements, maxSpatialCost_);
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);
210 ocean_assert(y < rowCost_.size());
211 rowCost_[y] = rowCost;
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:470
T x() const
Returns the horizontal coordinate position of this object.
Definition: PixelPosition.h:458
This class implements the base class for all creators that support mappings for one frame.
Definition: Creator1.h:28
This class implements the base class for all creators.
Definition: Creator.h:29
This class is the base class for all creators that support mappings with integer accuracy.
Definition: CreatorI.h:29
This class implements a creator that can be distributed to subsets of the synthesis layer.
Definition: CreatorSubset.h:28
bool invoke(Worker *worker=nullptr) const override
Invokes the creator.
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:634
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15