9 #include "compositer.hpp"
10 #include "feathering.hpp"
11 #include "laplacianPyramid.hpp"
20 _pyramidPanorama(outputWidth, outputHeight, scale + 1),
26 virtual bool initialize(
const BoundingBox& outputRoi)
28 _outputRoi = outputRoi;
30 if (_outputRoi.left < 0)
32 if (_outputRoi.top < 0)
34 if (_outputRoi.getRight() >= _panoramaWidth)
36 if (_outputRoi.getBottom() >= _panoramaHeight)
39 return _pyramidPanorama.initialize();
42 virtual int getBorderSize()
const {
return _gaussianFilterRadius; }
52 if (!feathering(feathered, color, inputMask))
60 for (
int i = 0; i < feathered.
height(); i++)
62 for (
int j = 0; j < feathered.
width(); j++)
64 feathered(i, j).r() = std::log(std::max(1e-8f, feathered(i, j).r()));
65 feathered(i, j).g() = std::log(std::max(1e-8f, feathered(i, j).g()));
66 feathered(i, j).b() = std::log(std::max(1e-8f, feathered(i, j).b()));
72 for (
int i = 0; i < inputMask.
height(); i++)
74 for (
int j = 0; j < inputMask.
width(); j++)
78 maskFloat(i, j) = 1.0f;
82 maskFloat(i, j) = 0.0f;
90 bb.width = feathered.
width();
91 bb.height = feathered.
height();
93 int scale = _bands - 1;
94 BoundingBox potbb = bb.divide(scale).dilate(getBorderSize()).multiply(scale);
97 contentbb.left = bb.left - potbb.left;
98 contentbb.top = bb.top - potbb.top;
100 if (!_pyramidPanorama.apply(feathered, maskFloat, inputWeights, potbb, contentbb))
108 virtual bool terminate()
112 if (!_pyramidPanorama.rebuild(_panorama, _outputRoi))
117 for (
int i = 0; i < _outputRoi.height; i++)
119 for (
int j = 0; j < _outputRoi.width; j++)
124 out.
r() = std::exp(c.
r());
125 out.
g() = std::exp(c.
g());
126 out.
b() = std::exp(c.
b());
129 _panorama(i, j) = out;
137 const int _gaussianFilterRadius = 2;