Skip to content
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

Implement Delta E 2000 to correct color perception #2638

Closed
kojoru opened this issue Sep 2, 2019 · 14 comments · Fixed by #11095
Closed

Implement Delta E 2000 to correct color perception #2638

kojoru opened this issue Sep 2, 2019 · 14 comments · Fixed by #11095
Labels
Area-Accessibility Issues related to accessibility Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.

Comments

@kojoru
Copy link
Contributor

kojoru commented Sep 2, 2019

Environment

Windows build number:  10.0.18362.0
Windows Terminal version : 0.4.2382.0
ConEmu version: 180626 

Steps to reproduce

  1. Copy the color palette for "<Solarized (John Doe)>" from ConEmu to terminal. Here's the relevant JSON:
        {   
            "white" : "#fdf6e3",
            "blue" : "#073642",
            "green" : "#586e75",
            "cyan" : "#657b83",
            "red" : "#dc322f",
            "purple" : "#6c71c4",
            "yellow" : "#cb4b16",
            "brightWhite" : "#eee8d5",
            "brightBlack" : "#93a1a1",
            "brightBlue" : "#268bd2",
            "brightGreen" : "#859900",
            "brightCyan" : "#2aa198",
            "brightRed" : "#839496",
            "brightPurple" : "#d33682",
            "brightYellow" : "#b58900",
            "black" : "#002B36",
            "background" : "#002B36",
            "foreground" : "#fdf6e3",
            "name" : "Solarized (John Doe)"
        }
  1. Set powershell's color scheme to "Solarized (John Doe)"
  2. Run [enum]::GetValues([System.ConsoleColor]) | Foreach-Object {Write-Host $_ -ForegroundColor $_} to admire the colors

Expected behavior

Colors look as nice as ConEmu's

Actual behavior

Most colors look nice and similar but "DarkBlue" looks completely different and way worse. See screenshot.
image

To get a somewhat similar color you need to set blue (DarkBlue) to something like "blue" : "#0B5669"
image

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Sep 2, 2019
@j4james
Copy link
Collaborator

j4james commented Sep 2, 2019

It looks to me like it's cmder that might be getting the color wrong. I suggest you try out those color values in an HTML document with a little test like this:

<body style="background:#002b36">
<div style="color:#073642">DarkBlue</div>
<div style="color:#586e75">DarkGreen</div>
<div style="color:#657b83">DarkCyan</div>
<div style="color:#dc322f">DarkRed</div>
<div style="color:#6c71c4">DarkMagenta</div>
</body>

As far as I can tell, that produces colors that exactly match what the Windows Terminal is showing.

@DHowett-MSFT
Copy link
Contributor

It looks like ConEmu does some cool stuff to make sure that a color can always be perceived. It bumps colors that could be invisible on a certain background up in perceptibility using the deltaE 2000 algorithm.

@DHowett-MSFT
Copy link
Contributor

It looks like ConEmu lets you configure that with its "Adjust lightness of indistinguishable text" option. I'm betting that if you turn it off, you'll see the same colors as in WT.

@kojoru
Copy link
Contributor Author

kojoru commented Sep 3, 2019

@DHowett fair enough! Should I then open a new issue to feature request the same in terminal or can we convert this one?

@WSLUser
Copy link
Contributor

WSLUser commented Sep 3, 2019

It would be pretty cool if we could do the same for Terminal. I had wondered why color output looked a bit different. Thanks for breaking it down @DHowett .

@bitcrazed bitcrazed changed the title Unexpected color output compared to Cmder/ConEmu Implement Delta E 101 to correct color perception Sep 9, 2019
@bitcrazed bitcrazed removed Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 9, 2019
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Sep 9, 2019
@bitcrazed bitcrazed added Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. Area-Accessibility Issues related to accessibility Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues labels Sep 9, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 9, 2019
@bitcrazed bitcrazed added this to the Terminal Backlog milestone Sep 9, 2019
@hectormz
Copy link

What would be needed/considered to implement this in Terminal?

@DHowett
Copy link
Member

DHowett commented May 22, 2020

All it would need is someone to do the work, and two people to review the pull request. 😄

I'd prefer to see a specification to answer a couple questions: would this happen during rendering? Color scheme loading? Is there somewhere we could, should cache colors? How do we hook this setting up into the layer it needs to go into? Should we nudge rgb or 256-color entries the same way as user-specified ones?

@hectormz
Copy link

Three very easy things 😅

I can't answer any of the specifics regarding how this or WT actually work.

This would only pertain to foreground/background compatibility right?

But I would happy be with just user-specified colors.

Nudging 256 color entries would be nice if it wasn't much more overhead, and was cached ahead of time. But looking beyond the scope of user-specified colors might cause this fix to grow too much.

For example, opacity or background images would mess up these adjustments, so I don't think that should be supported/fixed.

@CIPop
Copy link
Member

CIPop commented Jun 10, 2020

+1 on this. To avoid others wasting their time:

Solarized Dark is not supported on Terminal today (assuming that most people like to see what they are typing).
@DHowett was kind enough to suggest workarounds in #6424 if you're hitting these issues.

@DHowett DHowett changed the title Implement Delta E 101 to correct color perception Implement Delta E 2000 to correct color perception Jun 10, 2020
@kojoru
Copy link
Contributor Author

kojoru commented Jun 12, 2020

@CIPop I've been quite successfully using my patched version of Solarized (John Doe) snatched from ConEmu ever since I filed this issue. It goes as follows:

        {   
            "white" : "#fdf6e3",
            "blue" : "#0B5669",
            "green" : "#586e75",
            "cyan" : "#657b83",
            "red" : "#dc322f",
            "purple" : "#6c71c4",
            "yellow" : "#cb4b16",
            "brightWhite" : "#eee8d5",
            "brightBlack" : "#93a1a1",
            "brightBlue" : "#268bd2",
            "brightGreen" : "#859900",
            "brightCyan" : "#2aa198",
            "brightRed" : "#839496",
            "brightPurple" : "#d33682",
            "brightYellow" : "#b58900",
            "black" : "#002B36",
            "background" : "#002B36",
            "foreground" : "#fdf6e3",
            "name" : "Solarized (John Doe with contrast blue)"
        }

As compared to the built-in Solarized, it never produces any unreadable results and has decent difference between colors.
image

@WSLUser
Copy link
Contributor

WSLUser commented Jun 12, 2020

@kojoru I suggest sending a PR updating the default with this instead.

@kojoru
Copy link
Contributor Author

kojoru commented Jun 12, 2020

Fair enough! Will do.

@WSLUser
Copy link
Contributor

WSLUser commented Jun 12, 2020

This may help for anyone trying to implement this: http://www.easyrgb.com/en/math.php#text6. I got this website from the answer in https://stackoverflow.com/questions/5774152/calculate-how-humans-perceive-similarity-between-different-colours. We use chromium math functions in C++ so it just needs conversion to use that instead.

kojoru added a commit to kojoru/terminal that referenced this issue Jun 13, 2020
Based on the discussion in microsoft#2638 until the Delta E 2000 contrast algo is
implemented in Terminal, it would be great to have a Solarized Dark
color scheme that does actually have enough contrast to be realistically
used for powershell.

This color scheme is based on "Solarized (John Doe)" from ConEmu and
modified to have a more visible `DarkBlue` as also discussed in microsoft#2638
@ghost ghost added the In-PR This issue has a related PR label Aug 31, 2021
@ghost ghost closed this as completed in #11095 Oct 7, 2021
@ghost ghost removed the In-PR This issue has a related PR label Oct 7, 2021
ghost pushed a commit that referenced this issue Oct 7, 2021
- Implements the Delta E algorithm
- Uses the Delta E algorithm to precalculate adjusted foreground values based on possible foreground/background color pairs in the color table
- Adds a setting to use the adjusted foreground values when applicable

## PR Checklist
* [x] Closes #2638
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [x] I work here

## Validation Steps Performed
Before:
<img width="759" alt="color before" src="https://user-images.githubusercontent.com/26824113/131576768-b3b9eebd-5933-45de-8da8-88a985070312.png">

After (note dark blue):
<img width="760" alt="color after" src="https://user-images.githubusercontent.com/26824113/133158807-4e63198f-8a49-4d03-914e-55a5ad57d725.png">
@ghost ghost added the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label Oct 7, 2021
@ghost
Copy link

ghost commented Oct 20, 2021

🎉This issue was addressed in #11095, which has now been successfully released as Windows Terminal Preview v1.12.2922.0.:tada:

Handy links:

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Accessibility Issues related to accessibility Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants