Ocean
Loading...
Searching...
No Matches
CreatorInpaintingContentF1.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_F_1_H
9#define META_OCEAN_CV_SYNTHESIS_CREATOR_INPAINTING_CONTENT_F_1_H
10
17
18namespace Ocean
19{
20
21namespace CV
22{
23
24namespace Synthesis
25{
26
27/**
28 * 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.
29 * @see CreatorInpaintingContentI1
30 * @ingroup cvsynthesis
31 */
32class OCEAN_CV_SYNTHESIS_EXPORT CreatorInpaintingContentF1 :
33 virtual public CreatorFrame,
34 virtual public CreatorF,
35 virtual public CreatorSubset,
36 virtual public Creator1
37{
38 public:
39
40 /**
41 * Creates a new creator object.
42 * @param layer The layer that is used to create the information
43 * @param target The target frame that will receive the creator output
44 */
45 inline CreatorInpaintingContentF1(const LayerF1& layer, Frame& target);
46
47 protected:
48
49 /**
50 * Creates a subset of the information.
51 * @see CreatorSubset::createSubset().
52 */
53 void createSubset(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const override;
54
55 /**
56 * Specialization of the default function that creates a subset of the information.
57 * The template parameter specifies the number of channels of the target frame.<br>
58 * @param firstColumn First column to be handled
59 * @param numberColumns Number of columns to be handled
60 * @param firstRow First row to be handled
61 * @param numberRows Number of rows to be handled
62 * @tparam tChannels Number of data channels of the frame
63 */
64 template <unsigned int tChannels>
65 void createSubsetChannels(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const;
66};
67
69 Creator(layer),
70 CreatorFrame(layer, target),
71 CreatorF(layer),
72 CreatorSubset(layer),
73 Creator1(layer)
74{
75 // nothing to do here
76}
77
78template <unsigned int tChannels>
79void CreatorInpaintingContentF1::createSubsetChannels(const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int firstRow, const unsigned int numberRows) const
80{
81 const unsigned int layerWidth = layerF_.width();
82 const unsigned int layerHeight = layerF_.height();
83
84 ocean_assert(layerF_.mask().width() == layerWidth);
85 ocean_assert(layerF_.mask().height() == layerHeight);
86
87 uint8_t* const frameData = target_.data<uint8_t>();
88
89 const unsigned int framePaddingElements = target_.paddingElements();
90
91 for (unsigned int y = firstRow; y < firstRow + numberRows; ++y)
92 {
93 uint8_t* framePixel = target_.pixel<uint8_t>(firstColumn, y);
94 const uint8_t* maskPixel = layerF_.mask().constpixel<uint8_t>(firstColumn, y);
95 const Vector2* mappingPixel = layerF_.mapping()() + y * layerWidth + firstColumn;
96
97 for (unsigned int x = firstColumn; x < firstColumn + numberColumns; ++x)
98 {
99 if (*maskPixel != 0xFF)
100 {
101 const Vector2& position = *mappingPixel;
102
103 ocean_assert(position.x() >= 0 && position.y() >= 0 && position.x() <= Scalar(layerWidth - 1u) && position.y() <= Scalar(layerHeight - 1u));
104 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(frameData, layerWidth, layerHeight, framePaddingElements, position, framePixel);
105 }
106
107 framePixel += tChannels;
108 ++maskPixel;
109 ++mappingPixel;
110 }
111 }
112}
113
114}
115
116}
117
118}
119
120#endif // META_OCEAN_CV_SYNTHESIS_CREATOR_INPAINTING_CONTENT_F_1_H
This class implements the base class for all creators that support mappings for one frame.
Definition Creator1.h:28
This class is the base class for all creators that support mappings with float accuracy.
Definition CreatorF.h:29
const LayerF & layerF_
Specialized layer reference.
Definition CreatorF.h:41
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 implements a creator object that creates the final synthesis image for a mapping with floa...
Definition CreatorInpaintingContentF1.h:37
CreatorInpaintingContentF1(const LayerF1 &layer, Frame &target)
Creates a new creator object.
Definition CreatorInpaintingContentF1.h:68
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 CreatorInpaintingContentF1.h:79
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.
This class implements a creator that can be distributed to subsets of the synthesis layer.
Definition CreatorSubset.h:28
This class implements a single layer for pixel synthesis within one frame and sub-pixel accuracy.
Definition LayerF1.h:44
virtual const MappingF & mapping() const =0
Returns the mapping of this synthesis layer.
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 Ocean's image class.
Definition Frame.h:1808
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition Frame.h:4239
T * pixel(const unsigned int x, const unsigned int y, const unsigned int planeIndex=0u)
Returns the pointer to the data of a specific pixel.
Definition Frame.h:4289
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:4330
unsigned int paddingElements(const unsigned int planeIndex=0u) const
Returns the optional number of padding elements at the end of each row for a specific plane.
Definition Frame.h:4122
unsigned int width() const
Returns the width of the frame format in pixel.
Definition Frame.h:3170
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3175
const T & x() const noexcept
Returns the x value.
Definition Vector2.h:710
const T & y() const noexcept
Returns the y value.
Definition Vector2.h:722
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15