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 — API: add antialiased to interpolation-stage in image by jklymak · Pull Request #28061 · matplotlib/matplotlib Conversation
|
| if (dispx < 3) or (dispy < 3): | ||
| interpolation_stage = 'rgba' | ||
| else: | ||
| interpolation_stage = 'data' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there's a really sane default in the (pathological) case of an image being stretched along x and squeezed along y, but I'd have thought that the "neutral" solution would be to set the cutoff at dispx * dispy < 1 (or < 3)? i.e. rgba if there's fewer total pixels at the end than at the beginning, data, if there's more?
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.
I'm erring on the side of using 'rgba' if any down-sampling is occurring - 'rgba' works exactly the same as 'data' if there is up-sampling and interpolation is 'nearest', which is the default. The only issue with 'rgba' happens when the user wants to smooth upsampled pixels, and specifies 'sinc' or 'bilinear' (etc) smoothing. Given that, I'm willing to ask such users to definitively specify 'data' if they are on the cusp of downsampling and getting weird artifacts.
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.
can we stuff this and the kernel selection into a helper function so that they do not get out-of-sync?
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.
Yeah, I tried that but the kernel selection is buried at a different level in the code (in _resample) with different ways of getting the data and figure size, so I took the easy way out and quasi repeated the logic here. I think a reasonable follow up is simplifying _resample and this part of the code base.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
73269ae to
2679f98
Compare
|
As briefly mentioned during the call, perhaps the option could be named in a way that does not preclude the future addition of an interpolation_stage="norm" ("normed", i.e. post-normalized data) option, and thus also of interpolation_stage="norm" when upsampling / "rgba" when downsampling. For example the mixed options could be named |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I don't think that is a problem. However we still need a default, and I think using 'antialiased', the same as the interpolation keyword default, makes sense. Would it be a problem for that to by synonymous with 'up:data;down:rgba' if we wanted to offer that? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I guess the question is whether we'd be happy to change the meaning of "antialiased" to mean "up:norm,down:rgba" (which I consider a saner default) once "norm" comes in? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Oh, I see, sorry didn't catch on to that. Thats always an interesting question if one interpolates linearly or in log space. In my field, people sometimes interpolate in log space, and then say incorrect things about the (arithmetic) mean. Though I agree that there are aesthetic reasons to interpolate in log space depending on the problem. If we were to add a norm stage of interpolation, as a default, I would tend to err on the side of simple averaging (eg |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
OK; I guess this is not going to make it to 3.9(?) (If it does, let's just go with "antialiasing" for now and explicitly mark this name as experimental (...but default) and reserve the right to change it later.) |
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
eefc329 to
6791fb1
Compare
|
If possible, I'd like to get this in before moving on to the next tasks, (fixing the float scaling) and adding a "norm" interpolation_stage. Working off these changes will be easier than adding those features, going back to these changes and rebasing. The only drawback is that there may be a bit of test image churn, but I think it will be minimal. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d4cd758 to
afbdfd2
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Awesome improvement! 🚀
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| is carried out on the data provided by the user. If 'rgba', the | ||
| interpolation is carried out after the colormapping has been | ||
| applied (visual interpolation). | ||
| interpolation_stage : {'antialiased', 'data', 'rgba'}, default: 'antialiased' |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| interpolation_stage : {'antialiased', 'data', 'rgba'}, default: 'antialiased' | |
| interpolation_stage : {'antialiased', 'data', 'rgba'}, default: :rc:`interpolation_stage` |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| interpolation_stage : {'antialiased', 'data', 'rgba'}, default: 'antialiased' | ||
| If 'data', interpolation is carried out on the data provided by the user. | ||
| If 'rgba', the interpolation is carried out in RGBA-space after the | ||
| color-mapping has been applied (visual interpolation). If 'antialiased', |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is 'antialiased' the correct name?
The other two options 'data' and 'rgba' refer to types of data in the processing pipeline. In contrast 'antialiased' is an effect.
From https://en.wikipedia.org/wiki/Spatial_anti-aliasing:
In digital signal processing, spatial anti-aliasing is a technique for minimizing the distortion artifacts (aliasing) when representing a high-resolution image at a lower resolution.
In my understanding anti-aliasing is only connected to downsampling. It's thus surprising that a mode 'antialiased' tries to
cover down-sampling and up-sampling.
Suggestion: Simply use 'auto', which hints at "use the best (from existing modes 'data', 'rgba') for the given context".
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.
'antialiased' is meant to be the same for both interpolation and interpolation_stage keyword arguments. The analogy is with most viewers, which have an "antialiased" toggle, regardless of whether the image is actually up or downsampled.
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.
I see. But still the name does not speak to me. I recommend to get some opinions from core devs. If they are fine with the name, I'll give in.
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.
I think the trap were are in here is that for the interpolation kernel we went with "antialiased" (maybe "auto" would have been better there, but I think the case is less good there than here (as it only considers 2 of many possible. Either way, that is out the door and we should not change it). That leaves us with the choice between:
I come down on the side of "use the same name" when looking at the aggregate (even if though I think locally "auto" is better).
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.
Well, 'antialiased' is pretty new for interpolation. We could keep it, but add 'auto' and make that the default for both interpolation and interpolation_stage. A bit of doc rewriting...
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.
I think "auto" would be better for both as it implies some magic selection is going on for the user to determine what is best. I agree, it seems like we coudl point "antialiased" -> "auto" if a user inputs "antialiased" and just rewrite the docs to make everything show "auto" now.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| axs[0].set_title("interpolation='antialiased', stage='rgba'") | ||
| axs[0].imshow(np.triu(img), cmap=cm, norm=norm, interpolation_stage='rgba') | ||
|
|
||
| # Should be same as previous |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can you do a figure reference/test comparison test here instead with these two axes?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
2e22643 to
d0e3ce8
Compare
|
OK, changed the default from 'antialiased' to 'auto' Also changed interpolation default to 'auto' from 'antialiased'. Kept 'antialiased' for back compatibility, but should behave exactly as 'auto'. |
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.
Only minor documentation suggestions.
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 an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
imshow used to default to interpolating in data space. That makes sense for up-sampled images, but fails in odd ways for down-sampled images. Here we introduce a new default value for *interpolation_stage* 'antialiased', which changes the interpolation stage to 'rgba' if the data is downsampled or upsampled less than a factor of three. Apply suggestions from code review Co-authored-by: Thomas A Caswell <[email protected]>
Co-authored-by: Tim Hoffmann <[email protected]>
bd64bfc to
45fac07
Compare
|
Thanks for putting in the work to make these changes, @jklymak! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the help - the is a relatively big change, but hopefully will not cause too much blowback and reduce bug reports for weird under sampled images... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you everyone! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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.