Skip to content

Fix incorrect implementation of bilinear interpolation#240

Merged
mhasself merged 2 commits into
masterfrom
fix_bilin
Apr 21, 2026
Merged

Fix incorrect implementation of bilinear interpolation#240
mhasself merged 2 commits into
masterfrom
fix_bilin

Conversation

@amaurea

@amaurea amaurea commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Both the pixel index calculation and the weights calculation were wrong. I must have been asleep when implementing this originally.

…l index calculation and the weights calculation were wrong
@amaurea amaurea requested review from mhasself and skhrg April 17, 2026 18:36
skhrg
skhrg previously approved these changes Apr 20, 2026

@skhrg skhrg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to assume the .5 pix difference is correct, looks like a normal corner vs center of pixel thing.

The order of the weights in the interpolation now match what I have written in other places (checked against my thesis draft). So that now looks good as well.

Maybe more of a @mhasself question but it may be worth it to write a simple unit test to protect against regressions here?

@mhasself mhasself left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks.

@amaurea has agreed to make a quick unit test for this, then we'll get it merged and tagged.

@amaurea

amaurea commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

@skhrg Yes, the 0.5 thing is because for nearest neighbor you want to round to the closest integer, while for bilinear you want to find the pixel just before (floor) and just after (ceil = floor+1). I've done this right before and after, so I don't know what I was thinking that time.

@mhasself mhasself left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mhasself mhasself merged commit 04f32aa into master Apr 21, 2026
2 checks passed
@mhasself mhasself deleted the fix_bilin branch April 21, 2026 13:25
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