Skip to content

Commit 9ed98f3

Browse files
author
Fabien Servant
committed
Make sure remap do not ignore alpha
1 parent 04bd901 commit 9ed98f3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/aliceVision/image/remap.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ void remapInter(const Image<P> & source, const Image<Vec2> & map, const P& fillC
131131

132132
//Not using sampler as the neigborhood size is dynamic
133133

134-
P sum(0.0);
134+
P sum;
135+
sum.fill(0.0);
136+
135137
double wsum = 0.0;
136138

137139
for (int by = iy1; by < iy2; by++)
@@ -157,9 +159,16 @@ void remapInter(const Image<P> & source, const Image<Vec2> & map, const P& fillC
157159
// (bx + 1) - x1
158160
// or x2 - bx
159161
double xocc = std::max(0.0, std::min(double(bx + 1), x2) - std::max(double(bx), x1));
162+
163+
const P & pix = source(by, bx);
160164
double weight = yocc * xocc;
165+
166+
if constexpr (std::is_same<P, RGBAfColor>())
167+
{
168+
weight *= pix.a();
169+
}
161170

162-
sum += source(by, bx) * weight;
171+
sum += pix * weight;
163172
wsum += weight;
164173
}
165174
}
@@ -169,11 +178,6 @@ void remapInter(const Image<P> & source, const Image<Vec2> & map, const P& fillC
169178
if (wsum > 0.0)
170179
{
171180
sum /= wsum;
172-
173-
if constexpr (std::is_same<P, RGBAfColor>())
174-
{
175-
sum.a() = 1.0;
176-
}
177181
}
178182

179183
output(i, j) = sum;

0 commit comments

Comments
 (0)