Ocean
Layer.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_LAYER_H
9 #define META_OCEAN_CV_SYNTHESIS_LAYER_H
10 
13 
14 #include "ocean/base/Frame.h"
15 
17 
18 namespace Ocean
19 {
20 
21 namespace CV
22 {
23 
24 namespace Synthesis
25 {
26 
27 /**
28  * This class implements the base class for all inpainting layers.
29  * The inpainting layer holds one inpainting frame with a corresponding inpainting mask.<br>
30  * Frame and mask must have the same frame dimensions and pixel origins.<br>
31  * Optional, each layer can hold a bounding box enclosing the inpainting area to speedup the computation.
32  * @ingroup cvsynthesis
33  */
34 class OCEAN_CV_SYNTHESIS_EXPORT Layer
35 {
36  public:
37 
38  /**
39  * Returns the width of this layer.
40  * @return Layer with in pixel, with range [0, infinity)
41  */
42  inline unsigned int width() const;
43 
44  /**
45  * Returns the height of this layer.
46  * @return Layer height in pixel, with range [0, infinity)
47  */
48  inline unsigned int height() const;
49 
50  /**
51  * Returns the frame of this layer.
52  * @return Layer frame
53  */
54  inline const Frame& frame() const;
55 
56  /**
57  * Returns the frame of this layer.
58  * @return Layer frame
59  */
60  inline Frame& frame();
61 
62  /**
63  * Returns the mask of this layer.
64  * @return Layer mask
65  */
66  inline const Frame& mask() const;
67 
68  /**
69  * Returns the mask of this layer.
70  * @return Layer mask
71  */
72  inline Frame& mask();
73 
74  /**
75  * Returns the optional bounding box of this layer.
76  * @return Bounding box covering all mask pixels, if defined
77  */
78  inline const PixelBoundingBox& boundingBox() const;
79 
80  /**
81  * Returns the mapping of this synthesis layer.
82  * @return Synthesis mapping
83  */
84  virtual const Mapping& mapping() const = 0;
85 
86  /**
87  * Returns the mapping of this synthesis layer.
88  * @return Synthesis mapping
89  */
90  virtual Mapping& mapping() = 0;
91 
92  /**
93  * Returns whether this layer holds at least one pixel.
94  * @return True, if so
95  */
96  explicit inline operator bool() const;
97 
98  protected:
99 
100  /**
101  * Creates an empty inpainting layer.
102  */
103  Layer() = default;
104 
105  /**
106  * Copy constructor.
107  * The resulting layer will hold a copy of the underlying image data.
108  * @param layer The layer to be copied
109  */
110  Layer(const Layer& layer);
111 
112  /**
113  * Move constructor.
114  * @param layer The layer to be moved
115  */
116  Layer(Layer&& layer) noexcept;
117 
118  /**
119  * Creates a new inpainting layer by a given frame and corresponding mask.
120  * @param frame Inpainting frame for this layer
121  * @param mask Inpainting mask of this layer
122  * @param boundingBox Optional inpainting bounding box covering all mask pixels, if defined
123  */
124  Layer(Frame& frame, const Frame& mask, const PixelBoundingBox& boundingBox = PixelBoundingBox());
125 
126  /**
127  * Destructs the inpainting layer.
128  */
129  virtual ~Layer();
130 
131  /**
132  * Assign operator.
133  * Afterwards, this layer will hold a copy of the underlying image data.
134  * @param layer The layer to be copied
135  * @return Reference to this layer
136  */
137  Layer& operator=(const Layer& layer);
138 
139  /**
140  * Move operator.
141  * @param layer The layer to be moved
142  * @return Reference to this layer
143  */
144  Layer& operator=(Layer&& layer) noexcept;
145 
146  protected:
147 
148  /// Width of this synthesis layer in pixel, with range [0, infinity)
149  unsigned int width_ = 0u;
150 
151  /// Height of this synthesis layer in pixel, with range [0, infinity)
152  unsigned int height_ = 0u;
153 
154  /// Frame of the inpainting layer, never owning the memory.
156 
157  /// Mask of the inpainting layer, with same dimension and pixel origin as the defined frame, always owning the memory.
159 
160  /// Optional bounding box covering all mask pixels, if defined.
162 };
163 
164 inline unsigned int Layer::width() const
165 {
166  return width_;
167 }
168 
169 inline unsigned int Layer::height() const
170 {
171  return height_;
172 }
173 
174 inline const Frame& Layer::frame() const
175 {
176  return frame_;
177 }
178 
180 {
181  return frame_;
182 }
183 
184 inline const Frame& Layer::mask() const
185 {
186  return mask_;
187 }
188 
190 {
191  return mask_;
192 }
193 
195 {
196  return boundingBox_;
197 }
198 
199 inline Layer::operator bool() const
200 {
201  return width_ != 0u && height_ != 0u;
202 }
203 
204 }
205 
206 }
207 
208 }
209 
210 #endif // META_OCEAN_CV_SYNTHESIS_LAYER_1_H
This class implements the base class for all inpainting layers.
Definition: Layer.h:35
PixelBoundingBox boundingBox_
Optional bounding box covering all mask pixels, if defined.
Definition: Layer.h:161
unsigned int height() const
Returns the height of this layer.
Definition: Layer.h:169
unsigned int width_
Width of this synthesis layer in pixel, with range [0, infinity)
Definition: Layer.h:149
Layer & operator=(Layer &&layer) noexcept
Move operator.
Layer()=default
Creates an empty inpainting layer.
Frame frame_
Frame of the inpainting layer, never owning the memory.
Definition: Layer.h:155
virtual ~Layer()
Destructs the inpainting layer.
const Frame & mask() const
Returns the mask of this layer.
Definition: Layer.h:184
Layer & operator=(const Layer &layer)
Assign operator.
Layer(const Layer &layer)
Copy constructor.
virtual Mapping & mapping()=0
Returns the mapping of this synthesis layer.
Layer(Frame &frame, const Frame &mask, const PixelBoundingBox &boundingBox=PixelBoundingBox())
Creates a new inpainting layer by a given frame and corresponding mask.
unsigned int height_
Height of this synthesis layer in pixel, with range [0, infinity)
Definition: Layer.h:152
Frame mask_
Mask of the inpainting layer, with same dimension and pixel origin as the defined frame,...
Definition: Layer.h:158
virtual const Mapping & mapping() const =0
Returns the mapping of this synthesis layer.
unsigned int width() const
Returns the width of this layer.
Definition: Layer.h:164
Layer(Layer &&layer) noexcept
Move constructor.
const Frame & frame() const
Returns the frame of this layer.
Definition: Layer.h:174
const PixelBoundingBox & boundingBox() const
Returns the optional bounding box of this layer.
Definition: Layer.h:194
This class is the base class for all mappings.
Definition: Mapping.h:35
This class implements Ocean's image class.
Definition: Frame.h:1792
PixelBoundingBoxT< unsigned int > PixelBoundingBox
Definition of the default PixelBoundingBox object with data type allowing only positive coordinate va...
Definition: PixelBoundingBox.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15