8#ifndef META_OCEAN_CV_SYNTHESIS_MAPPING_H
9#define META_OCEAN_CV_SYNTHESIS_MAPPING_H
42 inline unsigned int width()
const;
48 inline unsigned int height()
const;
61 virtual void applyMapping(
Frame& frame,
const Frame& mask,
const unsigned int xStart,
const unsigned int xWidth,
const unsigned int yStart,
const unsigned int yHeight,
Worker* worker =
nullptr)
const = 0;
67 explicit inline operator bool()
const;
73 template <
unsigned int tChannels>
80 template <
unsigned int tChannels>
118 template <
unsigned int tChannels>
127 template <
unsigned int tChannels>
189 const unsigned int windowHalf = 2u;
203 OCEAN_SUPPRESS_UNUSED_WARNING(windowHalf);
207 width_(pixelMapping.width_),
218 const unsigned int windowHalf = 2u;
232 OCEAN_SUPPRESS_UNUSED_WARNING(windowHalf);
234 pixelMapping.width_ = 0u;
235 pixelMapping.height_ = 0u;
237 pixelMapping.appearanceCostNormalizationInt8_ = 0u;
238 pixelMapping.appearanceCostNormalizationInt16_ = 0u;
239 pixelMapping.appearanceCostNormalizationInt24_ = 0u;
240 pixelMapping.appearanceCostNormalizationInt32_ = 0u;
242 pixelMapping.sapatialCostNormalizationInt8_ = 0u;
243 pixelMapping.spatialCostNormalizationInt16_ = 0u;
244 pixelMapping.spatialCostNormalizationInt24_ = 0u;
245 pixelMapping.spatialCostNormalizationInt32_ = 0u;
260 const unsigned int windowHalf = 2u;
274 OCEAN_SUPPRESS_UNUSED_WARNING(windowHalf);
292inline Mapping::operator bool()
const
297template <
unsigned int tChannels>
329template <
unsigned int tChannels>
361template <
unsigned int tChannels>
369 unsigned int appearanceNormalization = tChannels * 255u * 255u;
372 if (appearanceNormalization > spatialCost)
374 appearanceNormalization = (appearanceNormalization + spatialCost / 2u) / spatialCost;
380 appearanceNormalization = 1u;
383 return appearanceNormalization;
386template <
unsigned int tChannels>
394 unsigned int appearanceNormalization = tChannels * 255u * 255u;
397 if (appearanceNormalization > spatialCost)
404 spatialCost = (spatialCost + appearanceNormalization / 2u) / appearanceNormalization;
431 if (
this != &mapping)
447 mapping.height_ = 0u;
449 mapping.appearanceCostNormalizationInt8_ = 0u;
450 mapping.appearanceCostNormalizationInt16_ = 0u;
451 mapping.appearanceCostNormalizationInt24_ = 0u;
452 mapping.appearanceCostNormalizationInt32_ = 0u;
454 mapping.sapatialCostNormalizationInt8_ = 0u;
455 mapping.spatialCostNormalizationInt16_ = 0u;
456 mapping.spatialCostNormalizationInt24_ = 0u;
457 mapping.spatialCostNormalizationInt32_ = 0u;
unsigned int width_
Width of this pixel mapping object in pixel.
Definition Mapping.h:147
unsigned int spatialCostNormalization() const
Calculates the normalization term for the spatial cost in accordance to the frame dimension of this m...
Definition Mapping.h:330
unsigned int width() const
Returns the width of this mapping object.
Definition Mapping.h:282
unsigned int spatialCostNormalizationInt32_
Spatial cost normalization factor for 4 channel 32 bit frames.
Definition Mapping.h:174
Mapping & operator=(const Mapping &mapping)
Assign operator.
Definition Mapping.h:411
unsigned int appearanceCostNormalizationInt32_
Appearance cost normalization factor for 4 channel 32 bit frames.
Definition Mapping.h:162
unsigned int appearanceCostNormalization() const
Calculates the normalization term for the appearance cost in accordance to the frame dimension of thi...
Definition Mapping.h:298
unsigned int spatialCostNormalizationInt16_
Spatial cost normalization factor for 2 channel 16 bit frames.
Definition Mapping.h:168
unsigned int height_
Height of this pixel mapping object in pixel.
Definition Mapping.h:150
unsigned int sapatialCostNormalizationInt8_
Spatial cost normalization factor for 1 channel 8 bit frames.
Definition Mapping.h:165
unsigned int spatialCostNormalizationInt24_
Spatial cost normalization factor for 3 channel 24 bit frames.
Definition Mapping.h:171
unsigned int height() const
Returns the height of this mapping object.
Definition Mapping.h:287
virtual ~Mapping()
Destructs a mapping object.
Definition Mapping.h:277
unsigned int calculateSpatialCostNormalization(const unsigned int width, const unsigned int height)
Calculates the normalization term for the spatial cost in accordance to a specified frame dimension.
Definition Mapping.h:387
unsigned int appearanceCostNormalizationInt16_
Appearance cost normalization factor for 2 channel 16 bit frames.
Definition Mapping.h:156
virtual void applyMapping(Frame &frame, const Frame &mask, const unsigned int xStart, const unsigned int xWidth, const unsigned int yStart, const unsigned int yHeight, Worker *worker=nullptr) const =0
Applies the current mapping for one given frame.
unsigned int appearanceCostNormalizationInt8_
Appearance cost normalization factor for 1 channel 8 bit frames.
Definition Mapping.h:153
static unsigned int calculateAppearanceCostNormalization(const unsigned int width, const unsigned int height)
Calculates the normalization term for the appearance cost in accordance to a specified frame dimensio...
Definition Mapping.h:362
unsigned int appearanceCostNormalizationInt24_
Appearance cost normalization factor for 3 channel 24 bit frames.
Definition Mapping.h:159
Mapping()=default
Creates a new mapping object.
This class implements Ocean's image class.
Definition Frame.h:1969
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
constexpr bool oceanFalse()
This function is a helper function returning false any time.
Definition Base.h:590
unsigned int sqr(const char value)
Returns the square value of a given value.
Definition base/Utilities.h:1099
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