Skip to content

Commit 2af8047

Browse files
author
Alex Biddulph
authored
Fix interpolation pixel selection (#10)
1 parent d0c5776 commit 2af8047

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cpp/visualmesh/engine/cpu/pixel.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ namespace engine {
130130
const Scalar y = P[1];
131131
const int x1 = std::max(int(std::floor(P[0])), 0);
132132
const int y1 = std::max(int(std::floor(P[1])), 0);
133-
const int x2 = std::max(x1 + 1, dimensions[0]);
134-
const int y2 = std::max(y1 + 1, dimensions[1]);
133+
const int x2 = std::min(x1 + 1, dimensions[0] - 1);
134+
const int y2 = std::min(y1 + 1, dimensions[1] - 1);
135135
const vec4<Scalar> Q1 = get_pixel<Scalar>(vec2<int>{x1, y1}, image, dimensions, format);
136136
const vec4<Scalar> Q2 = get_pixel<Scalar>(vec2<int>{x2, y1}, image, dimensions, format);
137137
const vec4<Scalar> Q3 = get_pixel<Scalar>(vec2<int>{x1, y2}, image, dimensions, format);

0 commit comments

Comments
 (0)