-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
API: add antialiased to interpolation-stage in image #28061
base: main
Are you sure you want to change the base?
Changes from all commits
51a7455
11f0359
122aaed
a8cf3b0
e64f8ba
afbdfd2
2e22643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
imshow *interpolation_stage* default changed to 'antialiased' | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The *interpolation_stage* keyword argument `~.Axes.imshow` has a new default | ||
value 'antialiased'. For images that are up-sampled less than a factor of | ||
three or down-sampled , image interpolation will occur in 'rgba' space. For images | ||
that are up-sampled by more than a factor of 3, then image interpolation occurs | ||
in 'data' space. | ||
|
||
The previous default was 'data', so down-sampled images may change subtly with | ||
the new default. However, the new default also avoids floating point artifacts | ||
at sharp boundaries in a colormap when down-sampling. | ||
|
||
The previous behavior can achieved by setting :rc:`image.interpolation_stage` or | ||
the *interpolation_stage* parameter in `~.axes.Axes.imshow` to 'data'. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5787,11 +5787,14 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None, | |
which can be set by *filterrad*. Additionally, the antigrain image | ||
resize filter is controlled by the parameter *filternorm*. | ||
|
||
interpolation_stage : {'data', 'rgba'}, default: 'data' | ||
If 'data', interpolation | ||
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' | ||
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 | ||
timhoffm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
color-mapping has been applied (visual interpolation). If 'antialiased', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is 'antialiased' the correct name?
Suggestion: Simply use 'auto', which hints at "use the best (from existing modes 'data', 'rgba') for the given context". There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... |
||
then 'rgba' is used if downsampling, or upsampling at a rate less than 3. | ||
If upsampling at a higher rate, then 'data' is used. | ||
See :doc:`/gallery/images_contours_and_fields/image_antialiasing` for | ||
a discussion of image antialiasing. | ||
|
||
alpha : float or array-like, optional | ||
The alpha blending value, between 0 (transparent) and 1 (opaque). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.