Skip to content

Resolve rounding issues in reduce #1872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2020
Merged

Conversation

kleisauke
Copy link
Member

This PR is a split-off from #1769, targeting the 8.10 branch.

It fixes two small bugs that have been found with jsummers/resamplescope. The first commit (kleisauke@49d8051) restores the round-to-nearest behaviour in reduce{h,v}, that was removed with PR #1592. This change can be observed in the following graphs:

Before After
pd_vips_lanczos3-out.png pd_vips_lanczos3-out.png
Rounding error

The second commit (kleisauke@fdc140e) rounds the sum values to the nearest integer in *_notab version. I'm not entirely sure why this is necessary and whether this is the right place to do it, but it seems to fix the double-precision graph:

Before After
pd_vips_lanczos3-out.png pd_vips_lanczos3-out.png
Rounding / offset error

The last commit (kleisauke@4533375) rounds the x and y values of the vips_embed call up and take this offset into account (i.e. by subtracting it from hoffset / voffset). Somehow I cannot illustrate this change within the graphs, but can confirm that this fixes the border-issues reported on sharp (lovell/sharp#2408 and lovell/sharp#2411). It also does not cause regressions on the pyvips-issue-148 and vips-issue-703 test repositories.

@lovell
Copy link
Member

lovell commented Nov 6, 2020

Thanks Kleis, this change looks good to me.

@jcupitt jcupitt merged commit a54cec9 into libvips:8.10 Dec 12, 2020
@jcupitt
Copy link
Member

jcupitt commented Dec 12, 2020

Looks good here too, nice work Kleis.

Sorry for being so slow on this. I finished my huge three-year project last night! \o/ so I should finally have some free time again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants