Skip to content

Commit cf2b13c

Browse files
authored
Merge pull request #30184 from ayshih/more_resample_bugs
Fixed several accuracy bugs with image resampling
2 parents 6208137 + c19b295 commit cf2b13c

54 files changed

Lines changed: 781 additions & 595 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

extern/agg24-svn/include/agg_image_filters.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,25 @@ namespace agg
5353
double r = filter.radius();
5454
realloc_lut(r);
5555
unsigned i;
56+
#ifndef MPL_FIX_AGG_IMAGE_FILTER_LUT_BUGS
5657
unsigned pivot = diameter() << (image_subpixel_shift - 1);
5758
for(i = 0; i < pivot; i++)
59+
#else
60+
unsigned pivot = (diameter() << (image_subpixel_shift - 1)) - 1;
61+
for(i = 0; i < pivot + 1; i++)
62+
#endif
5863
{
5964
double x = double(i) / double(image_subpixel_scale);
6065
double y = filter.calc_weight(x);
6166
m_weight_array[pivot + i] =
6267
m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale);
6368
}
6469
unsigned end = (diameter() << image_subpixel_shift) - 1;
70+
#ifndef MPL_FIX_AGG_IMAGE_FILTER_LUT_BUGS
6571
m_weight_array[0] = m_weight_array[end];
72+
#else
73+
m_weight_array[end] = (int16)iround(filter.calc_weight(diameter() / 2) * image_filter_scale);
74+
#endif
6675
if(normalization)
6776
{
6877
normalize();

extern/agg24-svn/include/agg_span_interpolator_linear.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ namespace agg
5353
//----------------------------------------------------------------
5454
void begin(double x, double y, unsigned len)
5555
{
56+
#ifdef MPL_FIX_AGG_INTERPOLATION_ENDPOINT_BUG
57+
len -= 1;
58+
#endif
59+
5660
double tx;
5761
double ty;
5862

@@ -75,6 +79,10 @@ namespace agg
7579
//----------------------------------------------------------------
7680
void resynchronize(double xe, double ye, unsigned len)
7781
{
82+
#ifdef MPL_FIX_AGG_INTERPOLATION_ENDPOINT_BUG
83+
len -= 1;
84+
#endif
85+
7886
m_trans->transform(&xe, &ye);
7987
m_li_x = dda2_line_interpolator(m_li_x.y(), iround(xe * subpixel_scale), len);
8088
m_li_y = dda2_line_interpolator(m_li_y.y(), iround(ye * subpixel_scale), len);

extern/agg24-svn/src/agg_image_filters.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ namespace agg
8888
}
8989
}
9090

91+
#ifndef MPL_FIX_AGG_IMAGE_FILTER_LUT_BUGS
9192
unsigned pivot = m_diameter << (image_subpixel_shift - 1);
9293

9394
for(i = 0; i < pivot; i++)
@@ -96,6 +97,7 @@ namespace agg
9697
}
9798
unsigned end = (diameter() << image_subpixel_shift) - 1;
9899
m_weight_array[0] = m_weight_array[end];
100+
#endif
99101
}
100102

101103

-48 Bytes
Binary file not shown.
-28 Bytes
Loading

lib/matplotlib/tests/baseline_images/test_axes/imshow.svg

Lines changed: 41 additions & 30 deletions
Loading
0 Bytes
Loading

lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.svg

Lines changed: 75 additions & 62 deletions
Loading
34 Bytes
Loading
-2.36 KB
Loading

0 commit comments

Comments
 (0)