Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

jklymak
Copy link
Member

PR Summary

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

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings andpydocstyle<4 and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@jklymak
Copy link
MemberAuthor

@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

importmatplotlib.colorsasmcolorsfig,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]=-1norm=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 featuresand 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
MemberAuthor

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

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.

@QuLogicQuLogic modified the milestones:v3.3-doc,v3.4.0Jan 28, 2021
@jklymakjklymakforce-pushed thedoc-update-antialiasing branch fromb3632a5 tob1492f9CompareFebruary 1, 2021 03:13
@jklymak
Copy link
MemberAuthor

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

Copy link
Member

@timhoffmtimhoffm left a comment
edited
Loading

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
MemberAuthor

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.

jklymak reacted with thumbs up emoji
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
MemberAuthor

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
MemberAuthor

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....

@jklymakjklymakforce-pushed thedoc-update-antialiasing branch fromf2d017b to3fa9867CompareFebruary 2, 2021 00:32
@jklymakjklymakforce-pushed thedoc-update-antialiasing branch from3fa9867 to44bfb9bCompareFebruary 4, 2021 19:02
@jklymakjklymak modified the milestones:v3.4.0,v3.4.1Feb 18, 2021
@QuLogicQuLogic modified the milestones:v3.4.1,v3.4-docMar 29, 2021
@jklymakjklymak marked this pull request as draftMay 8, 2021 20:46
@jklymak
Copy link
MemberAuthor

Ihope we will change this for 3.5, so this will probably be obsolete

@jklymak
Copy link
MemberAuthor

This is now obsolete

@jklymakjklymak deleted the doc-update-antialiasing branchDecember 11, 2022 21:42
@QuLogicQuLogic removed this from thev3.6-doc milestoneDec 13, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm left review comments

@tacaswelltacaswellAwaiting requested review from tacaswell

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@jklymak@tacaswell@QuLogic@timhoffm@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp