GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Fixed several accuracy bugs with image resampling by ayshih · Pull Request #30184 · matplotlib/matplotlib Conversation
|
| if(i <= pivot) m_weight_array[pivot - i] = value; | ||
| } | ||
| unsigned end = (diameter() << image_subpixel_shift) - 1; | ||
| m_weight_array[0] = m_weight_array[end]; |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This line is one of the bugs. 0 and end are different distances from pivot, so the corresponding weights typically should not be the same.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please put the new version under a macro guard, as was done in #28122, so that we keep a track of what's the original Agg and what we changed on top of it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It turns out that I can't add a preprocessor definition in _image_resample.h a la #28122. There is buggy code in agg_image_filters.cpp that needs to be skipped, but since it is a CPP file rather than a H file, it gets compiled separately with no awareness of _image_resample.h. I have put the preprocessor definition (MPL_FIX_IMAGE_FILTER_LUT_BUGS) here at the top of agg_image_filters.h, which is lower level than would be nice, but at least still makes it clear what is custom code.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You could also put the define in the corresponding meson.build if you prefer.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a nicer approach. Done!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
You can see such a blip in the example above, but it's easy to overlook. Here's a starker example: an array of two pixels with the same value (0.1) is resampled to an array of ten pixels. Before this PR, two of the pixels in the output array have values slightly greater than 0.1. >>> import numpy as np >>> from matplotlib.transforms import Affine2D >>> from matplotlib.image import resample, BILINEAR >>> >>> in_data = np.array([[0.1, 0.1]]) >>> in_shape = in_data.shape >>> >>> out_shape = (1, 10) >>> >>> # Create a simple affine transform for scaling the input array >>> affine = Affine2D().scale(sx=out_shape[1] / in_shape[1], sy=1) >>> >>> affine_data = np.empty(out_shape) >>> resample(in_data, affine_data, affine, interpolation=BILINEAR) >>> >>> print(affine_data) [[0.1 0.10001221 0.1 0.1 0.1 0.1 0.10001221 0.1 0.1 0.1 ]] After this PR, the output is the expected: >>> print(affine_data) [[0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]] |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d2fa1e5 to
7eb18b2
Compare
7eb18b2 to
d9f8bb5
Compare
|
This killed the log-scale images? Also this changed a bunch of image tests, but I can't see any difference by eye. Is it worth just relaxing the tolerance on those tests a bit and at the same time adding new tests for these fixes? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
7eb1cea to
5cbb7bb
Compare
Indeed, I need to track down why.
Yes, the other 17 image tests are mostly subtle differences, but merely relaxing the tolerance doesn't make sense to me. The updated baseline images do represent what the output should be. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Fair enough - however, it would be good if there were some tests devised where it showed a visual effect of these inaccuracies. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
e198af6 to
717a221
Compare
| } | ||
| } | ||
|
|
||
| #ifndef MPL_FIX_IMAGE_FILTER_LUT_BUGS |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The following code block is removed because it not only has the same bugs as the code in agg_image_filters.h, but also it shouldn't even exist because it modifies the weight array after it has been normalized, thus potentially destroying the normalization.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
43b912c to
90bd95f
Compare
|
I fixed the issue with On the other hand, most of the updated images have solely very slight changes in the appearance of text. As @jklymak suggested, it might make more sense in those cases to simply increase the tolerance instead for the comparison instead of updating the baseline image, so let me know if I should do that instead. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Are you sure you have the right set of images? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
OK, I see that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
90bd95f to
9fdca21
Compare
48e28b8 to
c19b295
Compare
|
I've updated this PR now that #30824 has been merged |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Whew, thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The tolerance on these was increased in various PRs, with notes to reduce/remove them, so they were removed in matplotlib#30184, but should have been reverted to a smaller value. - `test_floating_axes.py::test_curvelinear4[png]` fails on macOS - `test_grid_helper_curvelinear.py::test_axis_direction[png]` fails on ARM and macOS - `test_grid_helper_curvelinear.py::test_polar_box[png]` fails on Windows, ARM, and macOS These fail on macOS; there's a tolerance on them already, they fail by just a small amount, so increase it. - `test_patheffects.py::test_collection[png]` - `test_axes3d.py::test_scale3d_artists_log[png]`
The tolerance on these was increased in various PRs, with notes to reduce/remove them, so they were removed in matplotlib#30184, but should have been reverted to a smaller value. - `test_floating_axes.py::test_curvelinear4[png]` fails on macOS - `test_grid_helper_curvelinear.py::test_axis_direction[png]` fails on ARM and macOS - `test_grid_helper_curvelinear.py::test_polar_box[png]` fails on Windows, ARM, and macOS These fail on macOS; there's a tolerance on them already, they fail by just a small amount, so increase it. - `test_patheffects.py::test_collection[png]` - `test_axes3d.py::test_scale3d_artists_log[png]`
The tolerance on these was increased in various PRs, with notes to reduce/remove them, so they were removed in matplotlib#30184, but should have been reverted to a smaller value. - `test_floating_axes.py::test_curvelinear4[png]` fails on macOS - `test_grid_helper_curvelinear.py::test_axis_direction[png]` fails on ARM and macOS - `test_grid_helper_curvelinear.py::test_polar_box[png]` fails on Windows, ARM, and macOS These fail on macOS; there's a tolerance on them already, they fail by just a small amount, so increase it. - `test_bbox_tight.py::test_bbox_inches_tight_suptile_legend[png]` - `test_patheffects.py::test_collection[png]` - `test_axes3d.py::test_scale3d_artists_log[png]`
The tolerances on these were increased in various PRs, with notes to reduce/remove them, so they were removed in matplotlib#30184, but should have been reverted to a smaller value: - `test_floating_axes.py::test_curvelinear4[png]` fails on macOS - `test_grid_helper_curvelinear.py::test_axis_direction[png]` fails on ARM and macOS - `test_grid_helper_curvelinear.py::test_polar_box[png]` fails on Windows, ARM, and macOS These fail on macOS; there's tolerances on them already, they fail by just a small amount, so increase them: - `test_bbox_tight.py::test_bbox_inches_tight_suptile_legend[png]` - `test_patheffects.py::test_collection[png]` - `test_axes3d.py::test_scale3d_artists_log[png]` This fails only on AppVeyor (Windows), but not Azure. There is a tolerance there already, so just add it to the list: - `test_mathtext.py::test_mathtext_rendering`
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.