Skip to content

Doc update antialiasing #18749

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

Closed
wants to merge 4 commits into from
Closed

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Oct 15, 2020

PR Summary

Partially addresses #18735 by discussing colormapping in the context of anti-aliasing images...

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@jklymak jklymak force-pushed the doc-update-antialiasing branch from 9341f9b to c66256c Compare October 15, 2020 23:46
@jklymak jklymak added this to the v3.3-doc milestone Oct 15, 2020
@jklymak jklymak requested a review from tacaswell October 16, 2020 00:24
@jklymak
Copy link
Member Author

jklymak commented Oct 16, 2020

@tacaswell
Copy link
Member

I think that this needs a warning box that says "This may introduce colors to you images that are not in the color map, use this only if you are interested in qualitative images.". Probably also worth pointing out

I am not sure that this is the best justification for needing to do RGBA space interpolation though, you can get the same "clean up" of the edge of the disk by using "nearest" and also not get any not-in-the-colormap pixels

import matplotlib.colors as mcolors
fig, axs = plt.subplots(1, 2, figsize=(3.5, 2), sharex=True, sharey=True,
                        constrained_layout=True)
aa = np.ones_like(a)
aa[np.sqrt(R) < 0.5] = -1

norm = mcolors.Normalize(vmin=-1, vmax=1)

axs[0].imshow(aa, cmap='RdBu_r')
axs[0].set_title('Data antialiasing')
pc = axs[1].imshow(aa, interpolation='nearest', cmap='RdBu_r')
axs[1].set_title('Data Nearest')
plt.show()

nearest

I think this example should stay, but as a cautionary comment of "in some cases the hanning kernel may do things you wish it did not to big very sharp structures, in that case force back to 'nearest'".

If user data has both large infinitly sharp features and small fast oscillating features (other than that sounding like it involves some cool physics) is just a Hard Visualization Problem and they need more (screen (or detector)) pixels.


Personally I find the red-on-blue very hard to look at because my glasses have terrible chromatic aberration and if I turn my head the circle shifts a fair amount so it is very unclear to me what of what I am seeing is real in the image and what is a very local problem to my eyes (I see a pruple cresecent on one side and a white cerscent on the other!).

@jklymak
Copy link
Member Author

jklymak commented Oct 16, 2020

you can get the same "clean up" of the edge of the disk by using "nearest" and also not get any not-in-the-colormap pixels

yes, but then you will be susceptible to aliasing ;-). But I've changed the example to this to make that clear:

DiffAnti

@QuLogic
Copy link
Member

QuLogic commented Oct 16, 2020

I see a pruple cresecent on one side and a white cerscent on the other!.

I see this too, but I don't think it's real. If you copy the image to GIMP, rotate it 180 degrees, the purple crescent remains on the left, and white on the right. Whether it's due to RGBA pixel layouts or what, I'm not sure.

@QuLogic QuLogic modified the milestones: v3.3-doc, v3.4.0 Jan 28, 2021
@jklymak jklymak force-pushed the doc-update-antialiasing branch from b3632a5 to b1492f9 Compare February 1, 2021 03:13
@jklymak
Copy link
Member Author

jklymak commented Feb 1, 2021

This should still really go in the anti-aliasing discussion, even if #18782 goes in eventually.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Feel free to reword further. The proposed changes are not set in stone.

@@ -72,6 +74,73 @@
ax.set_title(f"interpolation='{interp}'")
plt.show()

###############################################################################
# Data antialiasing and RGBA antialiasing
Copy link
Member

Choose a reason for hiding this comment

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

I'd name this "Antialiasing colormapped data" and add a same-level "Antialiasing grayscale images".

And make some subsubsections here for "Data antialiasing" and "RGBA antialiasing".

// Well technically, grayscale is also a colormapping. The real difference is whether the colormapping is a straight line in RGB space or not. But I wouldn't go into the details here. Almost all colorful maps have quite some curve in RGB space.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not quite sure what you mean here? The first section was all about data antialiasing, with black and white chosen to make it obvious what was going one. This section is pointing out that this antialiasing is not the same as visual anti-aliasing.

constrained_layout=True)
for ax, interp in zip(axs, ['nearest', 'antialiased']):
pc = ax.imshow(a, interpolation=interp, cmap='RdBu_r', vmin=-1, vmax=1)
ax.set_title(f"'{interp}'", fontsize='small')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ax.set_title(f"'{interp}'", fontsize='small')
ax.set_title(f"'{interp}'")

I would not reduce the title size:

  • The titles are important for distinction if you only look at the image.
  • Consistency: All titles above use the original title size.

a_rgba = cmap(norm(a))
for ax, interp in zip(axs, ['nearest', 'antialiased']):
pc = ax.imshow(a_rgba, interpolation=interp)
ax.set_title(f"'{interp}'", fontsize='small')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ax.set_title(f"'{interp}'", fontsize='small')
ax.set_title(f"'{interp}'")

a_rgba = cmap(norm(aa))

axs[0].imshow(aa, interpolation='nearest', cmap='RdBu_r')
axs[0].set_title('No antialiasing')
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, CL sometimes has burbles like that if it is shrinking to fit rather than growing to fit. I just made the figure a bit bigger

Comment on lines 119 to 120
# is given here, where the anti-aliasing returns white pixels in data space,
# and (imperceptible) purple pixels in RGBA space:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# is given here, where the anti-aliasing returns white pixels in data space,
# and (imperceptible) purple pixels in RGBA space:
# is given here: All data points are either -1 or +1, corresponding to blue and red. The smoothing in data space can create any value between -1 and +1, and thus result in values that never occur in the original data (e.g. 0-valued pixels in white). Alternatively, when smoothing in RGBA space, we can get purple pixels as a mixture of blue and red. The disadvantage here is that these colors are not even in the colormap, and thus strictly have no meaning. However, visually they have a more intuitive "mixture of blue and red" appearance.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, modified this based on this suggestion....

@jklymak jklymak force-pushed the doc-update-antialiasing branch from f2d017b to 3fa9867 Compare February 2, 2021 00:32
@jklymak jklymak force-pushed the doc-update-antialiasing branch from 3fa9867 to 44bfb9b Compare February 4, 2021 19:02
@jklymak jklymak modified the milestones: v3.4.0, v3.4.1 Feb 18, 2021
@QuLogic QuLogic modified the milestones: v3.4.1, v3.4-doc Mar 29, 2021
@jklymak jklymak marked this pull request as draft May 8, 2021 20:46
@jklymak
Copy link
Member Author

jklymak commented May 8, 2021

I hope we will change this for 3.5, so this will probably be obsolete

@jklymak
Copy link
Member Author

jklymak commented Dec 11, 2022

This is now obsolete

@jklymak jklymak closed this Dec 11, 2022
@jklymak jklymak deleted the doc-update-antialiasing branch December 11, 2022 21:42
@QuLogic QuLogic removed this from the v3.6-doc milestone Dec 13, 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.

5 participants