Skip to content

Clip small linewidths in agg #14560

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timhoffm
Copy link
Member

PR Summary

Fixes #14498. See there for a full discussion.

Note: I've noticed that the following code uses a mixture of gc.linewidth (the original value) and linewidth (the clipped value). Can somebody with more Agg knowledge please check if that is correct?

// Too small linewidths are clipped because they require a lot of
// computation and do not make sense even with antialiasing.
// Compare github #14498.
linewidth = (linewidth < 0.01) ? 0.01 : mpl_round(linewidth);
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess clipping at 1/256 would make sense because the quantization of the channels is 8bit so linewidths<1/256 (or half that? perhaps...) would be quantized to zero.

Copy link
Member Author

Choose a reason for hiding this comment

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

What are channels in this context? I only know color channels but don't see how that could be related to linewidth.

Anyways, 0.01 causes some image comparison failures, trying 0.001 to see if that fixes it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant color channels.
With antialiasing, linewidths<1 are basically represented by setting the color channels to (linewidthreal_color) (blending with the background), but that's then quantized to 8 bits so linewidths<1/(2256) should result in nothing being drawn.

@timhoffm timhoffm force-pushed the clip-agg-linewidth branch from ed7f647 to 514484a Compare June 17, 2019 05:35
anntzer
anntzer previously approved these changes Jun 17, 2019
@anntzer anntzer dismissed their stale review June 17, 2019 05:43

... modulo CI

@timhoffm
Copy link
Member Author

timhoffm commented Jun 17, 2019

Still 44 image comparison failures for a cutoff at 0.001. Needs to be investigated, ... later.
I'm really surprised that the test suite contains code a all that triggers the cutoff. In particular, would that mean we have some performance bottlenecks builtin somewhere?

@anntzer
Copy link
Contributor

anntzer commented Jun 17, 2019

Possibly clip small linewidths to zero (i.e. don't draw them at all) instead of 0.001? just a random idea...

@timhoffm timhoffm force-pushed the clip-agg-linewidth branch from 514484a to 82b0415 Compare July 5, 2019 00:05
@timhoffm
Copy link
Member Author

timhoffm commented Jul 5, 2019

Try forcing linewidth < 0.001 to 0.

@timhoffm
Copy link
Member Author

timhoffm commented Jul 7, 2019

Interestingly, forcing linewidth < 0.001 to 0 causes a lot of image comparison failures with dashed lines having slightly modified widths.

@tacaswell tacaswell added this to the v3.3.0 milestone Aug 24, 2019
@QuLogic QuLogic modified the milestones: v3.3.0, v3.4.0 May 2, 2020
@jklymak jklymak marked this pull request as draft July 23, 2020 16:31
@timhoffm
Copy link
Member Author

Anybody can pick this up if wanted. I don't have the time to debug this for now.

@QuLogic QuLogic modified the milestones: v3.4.0, v3.5.0 Jan 21, 2021
@timhoffm timhoffm modified the milestones: v3.5.0, v3.6.0 Jul 11, 2021
@timhoffm timhoffm modified the milestones: v3.6.0, unassigned Apr 30, 2022
@story645 story645 modified the milestones: unassigned, needs sorting Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Freeze when setting dashed linewidth to a close-to-zero float
5 participants