Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2fa1e5

Browse files
committed
Fix bug with using the distortion table for nonaffine transformations
1 parent 26f0da7 commit d2fa1e5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ def inverted(self):
16751675
nonaffine_result = np.empty_like(expected)
16761676
mimage.resample(data, nonaffine_result, nonaffine_transform,
16771677
interpolation=interpolation)
1678-
assert_allclose(nonaffine_result, expected, atol=5e-3)
1678+
assert_allclose(nonaffine_result, expected, atol=2e-3)
16791679

16801680

16811681
def test_axesimage_get_shape():

src/_image_resample.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ class lookup_distortion
584584
if (dx >= 0 && dx < m_out_width &&
585585
dy >= 0 && dy < m_out_height) {
586586
const double *coord = m_mesh + (int(dy) * m_out_width + int(dx)) * 2;
587-
*x = int(coord[0] * agg::image_subpixel_scale);
588-
*y = int(coord[1] * agg::image_subpixel_scale);
587+
*x = int(coord[0] * agg::image_subpixel_scale + 0.5); // round
588+
*y = int(coord[1] * agg::image_subpixel_scale + 0.5); // round
589589
}
590590
}
591591
}

0 commit comments

Comments
 (0)