Ocean
Loading...
Searching...
No Matches
Optimizer4NeighborhoodReferenceFrameF1.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_OPTIMIZER_4_NEIGHBORHOOD_REFERENCE_FRAME_F_1_H
9#define META_OCEAN_CV_SYNTHESIS_OPTIMIZER_4_NEIGHBORHOOD_REFERENCE_FRAME_F_1_H
10
16
17#include "ocean/math/Random.h"
18
19namespace Ocean
20{
21
22namespace CV
23{
24
25namespace Synthesis
26{
27
28/**
29 * This class implements an optimizer for a mapping with float accuracy that uses a reference frame as additional optimization constraint.
30 * @tparam tWeightFactor Spatial weight impact, with range [0, infinity)
31 * @tparam tBorderFactor Weight factor of border pixels, with range [1, infinity)
32 * @tparam tUpdateFrame True, to update the frame pixel whenever a new mapping has been found
33 * @ingroup cvsynthesis
34 */
35template <unsigned int tWeightFactor, unsigned int tBorderFactor, bool tUpdateFrame>
37 virtual public OptimizerF,
38 virtual public OptimizerSubset,
39 virtual public Optimizer1
40{
41 public:
42
43 /**
44 * Creates a new optimizer object.
45 * @param layer Synthesis layer that will be optimized
46 * @param randomGenerator Random number generator
47 * @param reference The reference frame that is used during the optimization
48 */
49 inline Optimizer4NeighborhoodReferenceFrameF1(LayerF1& layer, RandomGenerator& randomGenerator, const Frame& reference);
50
51 private:
52
53 /**
54 * Optimizes a subset of the synthesis frame.
55 * @see Optimizer1::optimizeSubset().
56 * @see optimizerSubsetChannels().
57 */
58 void optimizeSubset(const unsigned int radii, const unsigned int maxSpatialCost, const unsigned int boundingBoxTop, const unsigned int boundingBoxHeight, const bool downIsMain, const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int rowOffset, const unsigned int firstRow, const unsigned int numberRows, const unsigned int threadIndex) const override;
59
60 /**
61 * Specialization of the default subset optimization function.
62 * The template parameters specified the number of channels the synthesis frame has.<br>
63 * @param radii Number of improvement radii during one optimization iteration for each mapping position
64 * @param maxSpatialCost Maximal spatial cost
65 * @param boundingBoxTop First row of the entire synthesis area
66 * @param boundingBoxHeight Number of rows of the entire synthesis area
67 * @param downIsMain True, if the downwards direction is the main optimization direction (for all subsets with even thread indices)
68 * @param firstColumn First column to be handled in the subset
69 * @param numberColumns Number of columns to be handled in the subset
70 * @param rowOffset Offset within the entire synthesis area (boundingBoxHeight), the subset may be moved by this offset
71 * @param firstRow First row to be handled in the subset
72 * @param numberRows Number of rows to be handled in the subset
73 * @param threadIndex Index of the thread that executes the subset optimization function
74 * @see optimizerSubset().
75 */
76 template <unsigned int tChannels>
77 void optimizeSubsetChannels(const unsigned int radii, const unsigned int maxSpatialCost, const unsigned int boundingBoxTop, const unsigned int boundingBoxHeight, const bool downIsMain, const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int rowOffset, const unsigned int firstRow, const unsigned int numberRows, const unsigned int threadIndex) const;
78
79 protected:
80
81 /// Specialized layer reference.
83
84 /// Reference frame that is used during the optimization.
86};
87
88template <unsigned int tWeightFactor, unsigned int tBorderFactor, bool tUpdateFrame>
90 Optimizer(layer),
91 OptimizerF(layer),
92 OptimizerSubset(layer, randomGenerator),
93 Optimizer1(layer),
94 layerF1_(layer),
95 referenceFrame_(reference)
96{
97 // nothing to do here
98}
99
100template <unsigned int tWeightFactor, unsigned int tBorderFactor, bool tUpdateFrame>
101void Optimizer4NeighborhoodReferenceFrameF1<tWeightFactor, tBorderFactor, tUpdateFrame>::optimizeSubset(const unsigned int radii, const unsigned int maxSpatialCost, const unsigned int boundingBoxTop, const unsigned int boundingBoxHeight, const bool downIsMain, const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int rowOffset, const unsigned int firstRow, const unsigned int numberRows, const unsigned int threadIndex) const
102{
103 ocean_assert(layerF1_.frame().numberPlanes() == 1u);
104
105 switch (layerF1_.frame().channels())
106 {
107 case 1u:
108 optimizeSubsetChannels<1u>(radii, maxSpatialCost, boundingBoxTop, boundingBoxHeight, downIsMain, firstColumn, numberColumns, rowOffset, firstRow, numberRows, threadIndex);
109 break;
110
111 case 2u:
112 optimizeSubsetChannels<2u>(radii, maxSpatialCost, boundingBoxTop, boundingBoxHeight, downIsMain, firstColumn, numberColumns, rowOffset, firstRow, numberRows, threadIndex);
113 break;
114
115 case 3u:
116 optimizeSubsetChannels<3u>(radii, maxSpatialCost, boundingBoxTop, boundingBoxHeight, downIsMain, firstColumn, numberColumns, rowOffset, firstRow, numberRows, threadIndex);
117 break;
118
119 case 4u:
120 optimizeSubsetChannels<4u>(radii, maxSpatialCost, boundingBoxTop, boundingBoxHeight, downIsMain, firstColumn, numberColumns, rowOffset, firstRow, numberRows, threadIndex);
121 break;
122
123 default:
124 ocean_assert(false && "Invalid frame type.");
125 }
126}
127
128template <unsigned int tWeightFactor, unsigned int tBorderFactor, bool tUpdateFrame>
129template <unsigned int tChannels>
130void Optimizer4NeighborhoodReferenceFrameF1<tWeightFactor, tBorderFactor, tUpdateFrame>::optimizeSubsetChannels(const unsigned int radii, const unsigned int maxSpatialCost, const unsigned int boundingBoxTop, const unsigned int boundingBoxHeight, const bool downIsMain, const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int rowOffset, const unsigned int firstRow, const unsigned int numberRows, const unsigned int threadIndex) const
131{
132 const unsigned int layerWidth = layerF1_.width();
133 const unsigned int layerHeight = layerF1_.height();
134
135 ocean_assert(layerWidth != 0u && layerHeight != 0u);
136
137 const std::vector<Scalar> searchRadii(calculateSearchRadii(radii, layerWidth, layerHeight));
138
139 Frame& layerFrame = layerF1_.frame();
140 const Frame& layerMask = layerF1_.mask();
141 MappingF1& layerMapping = layerF1_.mapping();
142
143 ocean_assert(layerWidth != 0u && layerHeight != 0u);
144 ocean_assert(FrameType::formatIsGeneric(layerFrame.pixelFormat(), FrameType::DT_UNSIGNED_INTEGER_8, tChannels));
145 ocean_assert(layerFrame.pixelOrigin() == layerMask.pixelOrigin());
146
147 ocean_assert(referenceFrame_.width() == layerWidth);
148 ocean_assert(referenceFrame_.height() == layerHeight);
149 ocean_assert(referenceFrame_.pixelOrigin() == layerFrame.pixelOrigin());
150
151 ocean_assert(firstColumn + numberColumns <= layerFrame.width());
152 ocean_assert(firstRow + numberRows <= layerFrame.height());
153
154 RandomGenerator generator(randomGenerator_);
155
156 uint8_t* const layerFrameData = layerFrame.data<uint8_t>();
157 const uint8_t* const layerMaskData = layerMask.constdata<uint8_t>();
158 const uint8_t* const referenceData = referenceFrame_.constdata<uint8_t>();
159
160 const unsigned int layerFramePaddingElements = layerFrame.paddingElements();
161 const unsigned int layerFrameStrideElements = layerFrame.strideElements();
162 const unsigned int layerMaskPaddingElements = layerMask.paddingElements();
163 const unsigned int layerMaskStrideElements = layerMask.strideElements();
164 const unsigned int referencePaddingElements = referenceFrame_.paddingElements();
165
166#ifdef OCEAN_DEBUG
167 const PixelBoundingBox& debugLayerBoundingBox = layerF1_.boundingBox();
168 ocean_assert(!debugLayerBoundingBox || firstRow >= debugLayerBoundingBox.top());
169 ocean_assert(!debugLayerBoundingBox || firstRow + numberRows <= debugLayerBoundingBox.bottomEnd());
170#endif // OCEAN_DEBUG
171
172 const bool down = (downIsMain && (threadIndex % 2u) == 0u) || (!downIsMain && (threadIndex % 2u) == 1u);
173
174 const unsigned int xStart = firstColumn;
175 const unsigned int yStart = firstRow;
176 const unsigned int xEnd = firstColumn + numberColumns;
177 const unsigned int yEnd = firstRow + numberRows;
178
179 ocean_assert(xEnd - xStart <= layerWidth);
180 ocean_assert(yEnd - yStart <= layerHeight);
181
182 if (down)
183 {
184 // find better positions for each mask pixel (top left to bottom right)
185 for (unsigned int yy = yStart; yy < yEnd; ++yy)
186 {
187 const unsigned int y = modulo(int(yy + rowOffset - boundingBoxTop), int(boundingBoxHeight)) + boundingBoxTop;
188
189 const uint8_t* maskRow = layerMask.constrow<uint8_t>(y) + xStart;
190 Vector2* positionRow = layerMapping.row(y) + xStart;
191
192 for (unsigned int x = xStart; x < xEnd; ++x)
193 {
194 bool foundBetter = false;
195
196 ocean_assert(maskRow == layerMask.constpixel<uint8_t>(x, y));
197 if (*maskRow != 0xFF)
198 {
199 Scalar newPositionX = positionRow->x();
200 Scalar newPositionY = positionRow->y();
201
202 const Scalar oldSpatialCost = layerMapping.spatialCost4Neighborhood<tChannels>(x, y, newPositionX, newPositionY, layerMaskData, layerMaskPaddingElements, Scalar(maxSpatialCost));
203 const unsigned int oldColorCost = layerMapping.appearanceReferenceCost5x5<tChannels>(x, y, newPositionX, newPositionY, layerFrameData, layerMaskData, referenceData, layerFramePaddingElements, layerMaskPaddingElements, referencePaddingElements, tBorderFactor);
204 Scalar newCost = Scalar(tWeightFactor) * oldSpatialCost + Scalar(oldColorCost);
205
206 Scalar testPositionX, testPositionY;
207
208 // first propagation from left to right
209 ocean_assert((maskRow - 1) == layerMask.constpixel<uint8_t>(x - 1u, y));
210 if (x > 0u && *(maskRow - 1) != 0xFFu)
211 {
212 ocean_assert(layerMapping.position(x - 1u, y).x() > 0);
213 ocean_assert(*(positionRow - 1) == layerMapping.position(x - 1, y));
214
215 // take the position to the left (of the current position)
216 testPositionX = (positionRow - 1)->x() + 1;
217 testPositionY = (positionRow - 1)->y();
218
219 if (testPositionX < Scalar(layerWidth - 3u) && layerMaskData[Numeric::round32(testPositionY) * layerMaskStrideElements + Numeric::round32(testPositionX)] == 0xFF)
220 {
221 // the structure cost is 0 due to the neighbor condition
222 const unsigned int testCost = layerMapping.appearanceReferenceCost5x5<tChannels>(x, y, testPositionX, testPositionY, layerFrameData, layerMaskData, referenceData, layerFramePaddingElements, layerMaskPaddingElements, referencePaddingElements, tBorderFactor);
223
224 if (Scalar(testCost) < newCost)
225 {
226 newPositionX = testPositionX;
227 newPositionY = testPositionY;
228 newCost = Scalar(testCost);
229 foundBetter = true;
230 }
231 }
232 }
233
234 // second propagation from top to bottom
235 ocean_assert((maskRow - layerMaskStrideElements) == layerMask.constpixel<uint8_t>(x, y - 1u));
236 if (y > 0u && *(maskRow - layerMaskStrideElements) != 0xFFu)
237 {
238 ocean_assert(layerMapping.position(x, y - 1).x() > 0);
239 ocean_assert(*(positionRow - layerWidth) == layerMapping.position(x, y - 1));
240
241 // take the next position to the top (of the current position)
242 testPositionX = (positionRow - layerWidth)->x();
243 testPositionY = (positionRow - layerWidth)->y() + 1;
244
245 if (testPositionY < Scalar(layerHeight - 3u) && layerMaskData[Numeric::round32(testPositionY) * layerMaskStrideElements + Numeric::round32(testPositionX)] == 0xFF)
246 {
247 // the structure cost is 0 due to the neighbor condition
248 const unsigned int testCost = layerMapping.appearanceReferenceCost5x5<tChannels>(x, y, testPositionX, testPositionY, layerFrameData, layerMaskData, referenceData, layerFramePaddingElements, layerMaskPaddingElements, referencePaddingElements, tBorderFactor);
249
250 if (Scalar(testCost) < newCost)
251 {
252 newPositionX = testPositionX;
253 newPositionY = testPositionY;
254 newCost = Scalar(testCost);
255 foundBetter = true;
256 }
257 }
258 }
259
260 // find a better position of the current mask pixel
261 for (unsigned int n = 0; n < radii; ++n)
262 {
263 ocean_assert(newPositionX != -1 && newPositionY != -1);
264
265 testPositionX = newPositionX + Random::scalar(generator, -searchRadii[n], searchRadii[n]);
266 testPositionY = newPositionY + Random::scalar(generator, -searchRadii[n], searchRadii[n]);
267
268 // the test position must lie inside the
269 if ((testPositionX == newPositionX && testPositionY == newPositionY) || testPositionX < Scalar(2) || testPositionX >= Scalar(layerWidth - 3u)
270 || testPositionY < Scalar(2) || testPositionY >= Scalar(layerHeight - 3u)
271 || layerMaskData[Numeric::round32(testPositionY) * layerMaskStrideElements + Numeric::round32(testPositionX)] != 0xFF)
272 continue;
273
274 const Scalar testSpatialCost = layerMapping.spatialCost4Neighborhood<tChannels>(x, y, testPositionX, testPositionY, layerMaskData, layerMaskPaddingElements, Scalar(maxSpatialCost));
275 const unsigned int testColorCost = layerMapping.appearanceReferenceCost5x5<tChannels>(x, y, testPositionX, testPositionY, layerFrameData, layerMaskData, referenceData, layerFramePaddingElements, layerMaskPaddingElements, referencePaddingElements, tBorderFactor);
276 const Scalar testCost = Scalar(tWeightFactor) * testSpatialCost + Scalar(testColorCost);
277
278 if (testCost < newCost)
279 {
280 newPositionX = testPositionX;
281 newPositionY = testPositionY;
282 newCost = Scalar(testCost);
283 foundBetter = true;
284 }
285 }
286
287 if (tUpdateFrame && foundBetter)
288 {
289 ocean_assert(layerMask.constpixel<uint8_t>(x, y)[0] != 0xFFu);
290 ocean_assert(layerMask.constpixel<uint8_t>(Numeric::round32(newPositionX), Numeric::round32(newPositionY))[0] == 0xFFu);
291
292 *positionRow = Vector2(newPositionX, newPositionY);
293
294 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(layerFrameData, layerWidth, layerHeight, layerFramePaddingElements, Vector2(newPositionX, newPositionY), layerFrameData + y * layerFrameStrideElements + x * tChannels);
295 }
296 }
297
298 ++maskRow;
299 ++positionRow;
300 }
301 }
302 }
303 else // up
304 {
305 // find better positions for each mask pixel (bottom right to top left)
306 for (unsigned int yy = yEnd - 1; yy != yStart - 1; --yy)
307 {
308 const unsigned int y = modulo(int(yy + rowOffset - boundingBoxTop), int(boundingBoxHeight)) + boundingBoxTop;
309
310 const uint8_t* maskRow = layerMask.constrow<uint8_t>(y) + xEnd - 1u;
311 Vector2* positionRow = layerMapping.row(y) + xEnd - 1u;
312
313 for (unsigned int x = xEnd - 1u; x != xStart - 1u; --x)
314 {
315 bool foundBetter = false;
316
317 ocean_assert(maskRow == layerMask.constpixel<uint8_t>(x, y));
318 if (*maskRow != 0xFFu)
319 {
320 Scalar newPositionX = positionRow->x();
321 Scalar newPositionY = positionRow->y();
322
323 const Scalar oldSpatialCost = layerMapping.spatialCost4Neighborhood<tChannels>(x, y, newPositionX, newPositionY, layerMaskData, layerMaskPaddingElements, Scalar(maxSpatialCost));
324 const unsigned int oldColorCost = layerMapping.appearanceReferenceCost5x5<tChannels>(x, y, newPositionX, newPositionY, layerFrameData, layerMaskData, referenceData, layerFramePaddingElements, layerMaskPaddingElements, referencePaddingElements, tBorderFactor);
325 Scalar newCost = Scalar(tWeightFactor) * oldSpatialCost + Scalar(oldColorCost);
326
327 Scalar testPositionX, testPositionY;
328
329 // first propagation from right to left
330 ocean_assert((maskRow + 1) == layerMask.constpixel<uint8_t>(x + 1u, y));
331 if (x < layerWidth - 1u && *(maskRow + 1) != 0xFFu)
332 {
333 ocean_assert(layerMapping.position(x + 1, y).x() > 0);
334 ocean_assert(*(positionRow + 1) == layerMapping.position(x + 1, y));
335
336 // take the position to the right (of the current position)
337 testPositionX = (positionRow + 1)->x() - 1;
338 testPositionY = (positionRow + 1)->y();
339
340 if (testPositionX >= Scalar(2) && layerMaskData[Numeric::round32(testPositionY) * layerMaskStrideElements + Numeric::round32(testPositionX)] == 0xFF)
341 {
342 // the structure cost is 0 due to the neighbor condition
343 const unsigned int testCost = layerMapping.appearanceReferenceCost5x5<tChannels>(x, y, testPositionX, testPositionY, layerFrameData, layerMaskData, referenceData, layerFramePaddingElements, layerMaskPaddingElements, referencePaddingElements, tBorderFactor);
344
345 if (Scalar(testCost) < newCost)
346 {
347 newPositionX = testPositionX;
348 newPositionY = testPositionY;
349 newCost = Scalar(testCost);
350 foundBetter = true;
351 }
352 }
353 }
354
355 // second propagation from bottom to top
356 ocean_assert((maskRow + layerMaskStrideElements) == layerMask.constpixel<uint8_t>(x, y + 1u));
357 if (y < layerHeight - 1u && *(maskRow + layerMaskStrideElements) != 0xFFu)
358 {
359 ocean_assert(layerMapping.position(x, y + 1).x() > 0);
360 ocean_assert(*(positionRow + layerWidth) == layerMapping.position(x, y + 1));
361
362 // take the next position towards the bottom (of the current position)
363 testPositionX = (positionRow + layerWidth)->x();
364 testPositionY = (positionRow + layerWidth)->y() - 1;
365
366 if (testPositionY >= Scalar(2) && layerMaskData[Numeric::round32(testPositionY) * layerMaskStrideElements + Numeric::round32(testPositionX)] == 0xFF)
367 {
368 // the structure cost is 0 due to the neighbor condition
369 const unsigned int testCost = layerMapping.appearanceReferenceCost5x5<tChannels>(x, y, testPositionX, testPositionY, layerFrameData, layerMaskData, referenceData, layerFramePaddingElements, layerMaskPaddingElements, referencePaddingElements, tBorderFactor);
370
371 if (Scalar(testCost) < newCost)
372 {
373 newPositionX = testPositionX;
374 newPositionY = testPositionY;
375 newCost = Scalar(testCost);
376 foundBetter = true;
377 }
378 }
379 }
380
381 // find a better position of the current mask pixel
382 for (unsigned int n = 0; n < radii; ++n)
383 {
384 ocean_assert(newPositionX != -1 && newPositionY != -1);
385
386 testPositionX = newPositionX + Random::scalar(generator, -searchRadii[n], searchRadii[n]);
387 testPositionY = newPositionY + Random::scalar(generator, -searchRadii[n], searchRadii[n]);
388
389 if ((testPositionX == newPositionX && testPositionY == newPositionY) || testPositionX < Scalar(2) || testPositionX >= Scalar(layerWidth - 3u)
390 || testPositionY < Scalar(2) || testPositionY >= Scalar(layerHeight - 3u)
391 || layerMaskData[Numeric::round32(testPositionY) * layerMaskStrideElements + Numeric::round32(testPositionX)] != 0xFF)
392 continue;
393
394 const Scalar testSpatialCost = layerMapping.spatialCost4Neighborhood<tChannels>(x, y, testPositionX, testPositionY, layerMaskData, layerMaskPaddingElements, Scalar(maxSpatialCost));
395 const unsigned int testColorCost = layerMapping.appearanceReferenceCost5x5<tChannels>(x, y, testPositionX, testPositionY, layerFrameData, layerMaskData, referenceData, layerFramePaddingElements, layerMaskPaddingElements, referencePaddingElements, tBorderFactor);
396 const Scalar testCost = Scalar(tWeightFactor) * testSpatialCost + Scalar(testColorCost);
397
398 if (testCost < newCost)
399 {
400 newPositionX = testPositionX;
401 newPositionY = testPositionY;
402 newCost = Scalar(testCost);
403 foundBetter = true;
404 }
405 }
406
407 if (tUpdateFrame && foundBetter)
408 {
409 ocean_assert(layerMask.constpixel<uint8_t>(x, y)[0] != 0xFFu);
410 ocean_assert(layerMask.constpixel<uint8_t>(Numeric::round32(newPositionX), Numeric::round32(newPositionY))[0] == 0xFFu);
411
412 *positionRow = Vector2(newPositionX, newPositionY);
413
414 CV::FrameInterpolatorBilinear::interpolatePixel8BitPerChannel<tChannels, CV::PC_TOP_LEFT>(layerFrameData, layerWidth, layerHeight, layerFramePaddingElements, Vector2(newPositionX, newPositionY), layerFrameData + y * layerFrameStrideElements + x * tChannels);
415 }
416 }
417
418 --maskRow;
419 --positionRow;
420 }
421 }
422 }
423}
424
425}
426
427}
428
429}
430
431#endif // META_OCEAN_CV_SYNTHESIS_OPTIMIZER_4_NEIGHBORHOOD_REFERENCE_FRAME_F_1_H
T bottomEnd() const
Returns the bottom (excluding) pixel position of this bounding box.
Definition PixelBoundingBox.h:451
T top() const
Returns the top (including) pixel position of this bounding box.
Definition PixelBoundingBox.h:423
This class implements a single layer for pixel synthesis within one frame and sub-pixel accuracy.
Definition LayerF1.h:44
Cost function:
Definition MappingF1.h:52
unsigned int appearanceReferenceCost5x5(const unsigned int xTarget, const unsigned int yTarget, const Scalar xSource, const Scalar ySource, const uint8_t *frame, const uint8_t *mask, const uint8_t *reference, const unsigned int framePaddingElements, const unsigned int maskPaddingElements, const unsigned int referencePaddingElements, const unsigned int borderFactor) const
Calculates the appearance cost for a given point between two given frames.
Definition MappingF1.h:317
Scalar spatialCost4Neighborhood(const unsigned int xTarget, const unsigned int yTarget, const Scalar xSource, const Scalar ySource, const uint8_t *targetMask, const unsigned int targetMaskPaddingElements, const Scalar maxCost) const
Calculates the smallest/cheapest spatial cost for a given point in a four-neighborhood and normalizes...
Definition MappingF1.h:259
const Vector2 * row(const unsigned int y) const
Returns the pointer to a mapping row.
Definition MappingF.h:210
const Vector2 & position(const unsigned int x, const unsigned int y) const
Returns the mapping for a given position.
Definition MappingF.h:189
This class implements the base class for all synthesis optimizers that use one single frame.
Definition Optimizer1.h:28
This class implements an optimizer for a mapping with float accuracy that uses a reference frame as a...
Definition Optimizer4NeighborhoodReferenceFrameF1.h:40
void optimizeSubset(const unsigned int radii, const unsigned int maxSpatialCost, const unsigned int boundingBoxTop, const unsigned int boundingBoxHeight, const bool downIsMain, const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int rowOffset, const unsigned int firstRow, const unsigned int numberRows, const unsigned int threadIndex) const override
Optimizes a subset of the synthesis frame.
Definition Optimizer4NeighborhoodReferenceFrameF1.h:101
void optimizeSubsetChannels(const unsigned int radii, const unsigned int maxSpatialCost, const unsigned int boundingBoxTop, const unsigned int boundingBoxHeight, const bool downIsMain, const unsigned int firstColumn, const unsigned int numberColumns, const unsigned int rowOffset, const unsigned int firstRow, const unsigned int numberRows, const unsigned int threadIndex) const
Specialization of the default subset optimization function.
Definition Optimizer4NeighborhoodReferenceFrameF1.h:130
Optimizer4NeighborhoodReferenceFrameF1(LayerF1 &layer, RandomGenerator &randomGenerator, const Frame &reference)
Creates a new optimizer object.
Definition Optimizer4NeighborhoodReferenceFrameF1.h:89
LayerF1 & layerF1_
Specialized layer reference.
Definition Optimizer4NeighborhoodReferenceFrameF1.h:82
const Frame & referenceFrame_
Reference frame that is used during the optimization.
Definition Optimizer4NeighborhoodReferenceFrameF1.h:85
This class is the base class for all optimizers that use a mapping with float accuracy.
Definition OptimizerF.h:29
This class is the base class for all synthesis optimizers.
Definition Optimizer.h:30
This class is the base class for all optimizers that are able to optimize seperate subsets of the syn...
Definition OptimizerSubset.h:30
This class implements Ocean's image class.
Definition Frame.h:1808
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:4138
const T * constdata(const unsigned int planeIndex=0u) const
Returns a pointer to the read-only pixel data of a specific plane.
Definition Frame.h:4248
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition Frame.h:4239
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
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:4273
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
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition Frame.h:3215
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition Frame.h:3180
@ DT_UNSIGNED_INTEGER_8
Unsigned 8 bit integer data type (uint8_t).
Definition Frame.h:41
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3175
static bool formatIsGeneric(const PixelFormat pixelFormat, const DataType dataType, const uint32_t channels, const uint32_t planes=1u, const uint32_t widthMultiple=1u, const uint32_t heightMultiple=1u)
Checks whether a given pixel format is a specific layout regarding data channels and data type.
Definition Frame.h:3435
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition Numeric.h:2064
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
static T scalar(const T lower, const T upper)
Returns a random number between two borders.
Definition Random.h:388
const T & x() const noexcept
Returns the x value.
Definition Vector2.h:710
T modulo(const T &value, const T &ring)
Returns the modulo value of a given parameter within a ring allowing positive and negative parameters...
Definition base/Utilities.h:924
float Scalar
Definition of a scalar type.
Definition Math.h:129
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
The namespace covering the entire Ocean framework.
Definition Accessor.h:15