Ocean
Loading...
Searching...
No Matches
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
20namespace Ocean
21{
22
23namespace CV
24{
25
26namespace 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 */
34class 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
80template <unsigned int tChannels>
81void 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 using PixelType = typename DataType<uint8_t, tChannels>::Type;
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:468
T x() const
Returns the horizontal coordinate position of this object.
Definition PixelPosition.h:456
Creator1(const Layer &layer)
Creates a new creator object.
Definition Creator1.h:38
CreatorFrame(const Layer &layer, Frame &target)
Creates a new creator object.
Definition CreatorFrame.h:44
Frame & target_
Target frame of the creator.
Definition CreatorFrame.h:41
This class implements the base class for all creators.
Definition Creator.h:29
const LayerI & layerI_
Specialized layer reference.
Definition CreatorI.h:41
CreatorI(const LayerI &layer)
Creates a new creator object.
Definition CreatorI.h:44
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
CreatorSubset(const Layer &layer)
Creates a new creator object.
Definition CreatorSubset.h:55
This class implements a single layer for pixel synthesis within one frame and pixel accuracy.
Definition LayerI1.h:41
This class implements Ocean's image class.
Definition Frame.h:1969
PixelPositionT< unsigned int > PixelPosition
Definition of the default PixelPosition object with a data type allowing only positive coordinate val...
Definition PixelPosition.h:32
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
Default definition of a type with tBytes bytes.
Definition DataType.h:32