mirror of
https://github.com/opencv/opencv.git
synced 2025-01-20 15:59:24 +08:00
Fixed rounding anf improved interpolation precision in hlineResize function
This commit is contained in:
parent
dc6fe87835
commit
ccfe28681d
@ -88,11 +88,12 @@ static void hlineResize(ET* src, int cn, int *ofst, FT* m, FT* dst, int dst_min,
|
||||
ET* src_ofst = src + cn*ofst[i];
|
||||
for (int j = 0; j < cn; j++, dst++)
|
||||
{
|
||||
*dst = (mulall || !m[0].isZero()) ? m[0] * src_ofst[j] : FT::zero();
|
||||
for (int k = 1; k < n; k++)
|
||||
FT result = FT::zero(); // Use a high precision type (FT) for the result
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
*dst = *dst + ((mulall || !m[k].isZero()) ? m[k] * src_ofst[j+k*cn] : FT::zero());
|
||||
result = result + ((mulall || !m[k].isZero()) ? m[k] * src_ofst[j+k*cn] : FT::zero());
|
||||
}
|
||||
*dst = (ET) std::min(std::max((int)(static_cast<float>(result) + 0.5f), 0), 255);
|
||||
}
|
||||
}
|
||||
// Avoid reading a potentially unset ofst, leading to a random memory read.
|
||||
|
Loading…
Reference in New Issue
Block a user