Ocean
CreatorInpaintingContentI1.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_CV_SYNTHESIS_CREATOR_INPAINTING_CONTENT_I_1_H
9 #define META_OCEAN_CV_SYNTHESIS_CREATOR_INPAINTING_CONTENT_I_1_H
10 
17 
18 #include "ocean/base/DataType.h"
19 
20 namespace Ocean
21 {
22 
23 namespace CV
24 {
25 
26 namespace Synthesis
27 {
28 
29 /**
30  * This class implements a creator object that creates the final synthesis image for a mapping with float accuracy and a mapping within the same frame.
31  * @see CreatorInpaintingContentF1
32  * @ingroup cvsynthesis
33  */
34 class OCEAN_CV_SYNTHESIS_EXPORT CreatorInpaintingContentI1 :
35  virtual public CreatorFrame,
36  virtual public CreatorI,
37  virtual public CreatorSubset,
38  virtual public Creator1
39 {
40  public:
41 
42  /**
43  * Creates a new creator object.
44  * @param layer The layer that is used to create the information
45  * @param target The target frame that will receive the creator output
46  */
47  inline CreatorInpaintingContentI1(const LayerI1& layer, Frame& target);
48 
49  protected:
50 
51  /**
52  * Creates a subset of the information.
53  * @see CreatorSubset::createSubset().
54  */
55  void createSubset(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const override;
56 
57  /**
58  * Specialization of the default function that creates a subset of the information.
59  * The template parameter specifies the number of channels of the target frame.
60  * @param firstColumn First column to be handled
61  * @param numberColumns Number of columns to be handled
62  * @param firstRow First row to be handled
63  * @param numberRows Number of rows to be handled
64  * @tparam tChannels Number of data channels of the frame
65  */
66  template <unsigned int tChannels>
67  void createSubsetChannels(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const;
68 };
69 
71  Creator(layer),
72  CreatorFrame(layer, target),
73  CreatorI(layer),
74  CreatorSubset(layer),
75  Creator1(layer)
76 {
77  // nothing to do here
78 }
79 
80 template <unsigned int tChannels>
81 void CreatorInpaintingContentI1::createSubsetChannels(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const
82 {
83  ocean_assert(firstColumn + numberColumns <= layerI_.width());
84  ocean_assert(firstRow + numberRows <= layerI_.height());
85 
86  typedef typename DataType<uint8_t, tChannels>::Type PixelType;
87 
88  const uint8_t* targetData = target_.data<uint8_t>();
89 
90  const unsigned int targetStrideElements = target_.strideElements();
91 
92  for (unsigned int y = firstRow; y < firstRow + numberRows; ++y)
93  {
94  PixelType* targetRow = target_.row<PixelType>(y);
95 
96  const uint8_t* maskRow = layerI_.mask().constrow<uint8_t>(y);
97  const PixelPosition* mappingRow = layerI_.mapping().row(y);
98 
99  for (unsigned int x = firstColumn; x < firstColumn + numberColumns; ++x)
100  {
101  if (maskRow[x] != 0xFFu)
102  {
103  const PixelPosition& mapping = mappingRow[x];
104 
105  ocean_assert(mapping.isValid() && mapping.x() < layerI_.width() && mapping.y() < layerI_.height());
106  ocean_assert(layerI_.mask().constpixel<uint8_t>(mapping.x(), mapping.y())[0] == 0xFFu);
107 
108  targetRow[x] = *((const PixelType*)(targetData + mapping.y() * targetStrideElements) + mapping.x());
109  }
110  }
111  }
112 }
113 
114 }
115 
116 }
117 
118 }
119 
120 #endif // META_OCEAN_CV_SYNTHESIS_CREATOR_INPAINTING_CONTENT_I_1_H
bool isValid() const
Returns whether this pixel position object holds two valid parameters.
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 creator objects that create a resulting frame as output.
Definition: CreatorFrame.h:28
Frame & target_
Target frame of the creator.
Definition: CreatorFrame.h:41
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
const LayerI & layerI_
Specialized layer reference.
Definition: CreatorI.h:41
This class implements a creator object that creates the final synthesis image for a mapping with floa...
Definition: CreatorInpaintingContentI1.h:39
void createSubsetChannels(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const
Specialization of the default function that creates a subset of the information.
Definition: CreatorInpaintingContentI1.h:81
void createSubset(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const override
Creates a subset of the information.
CreatorInpaintingContentI1(const LayerI1 &layer, Frame &target)
Creates a new creator object.
Definition: CreatorInpaintingContentI1.h:70
This class implements a creator that can be distributed to subsets of the synthesis layer.
Definition: CreatorSubset.h:28
unsigned int height() const
Returns the height of this layer.
Definition: Layer.h:169
const Frame & mask() const
Returns the mask of this layer.
Definition: Layer.h:184
unsigned int width() const
Returns the width of this layer.
Definition: Layer.h:164
This class implements a single layer for pixel synthesis within one frame and pixel accuracy.
Definition: LayerI1.h:41
virtual const MappingI & mapping() const =0
Returns the mapping of this synthesis layer.
const PixelPosition * row(const unsigned int y) const
Returns the pointer to a mapping row.
Definition: MappingI.h:243
Template class allowing to define an array of data types.
Definition: DataType.h:27
This class implements Ocean's image class.
Definition: Frame.h:1760
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:4026
T * row(const unsigned int y, const unsigned int planeIndex=0u)
Returns the pointer to the pixel data of a specific row.
Definition: Frame.h:4145
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition: Frame.h:4127
const T * constpixel(const unsigned int x, const unsigned int y, const unsigned int planeIndex=0u) const
Returns the pointer to the constant data of a specific pixel.
Definition: Frame.h:4218
const T * constrow(const unsigned int y, const unsigned int planeIndex=0u) const
Returns the pointer to the constant data of a specific row.
Definition: Frame.h:4161
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15