2021-04-28

再度音乐寻宝

平时脑子里会无缘无故,不由自主地蹦出一些旋律。这些旋律很熟悉,也肯定不是自己现编的,但是就是想不起来具体的名字,歌手或者哪里听到的。

最简单的情况是记得歌词,或者可以哼唱检索。最难的大概是影视作品的配乐,我觉得成功的配乐会让人记得当时的“感觉”而不是曲子本身的细节。

继上次音乐寻宝之后,又一个旋律出现了,令我吃不香睡不着。

经过几天的查找,最终还是找到了,结果是井上昌己的《Up Side Down 永遠の環》,出自圣少女的ED。过程还是挺有趣的。

1. 我大概记得开头intro的旋律,以及歌词的整体节奏,类似词牌。然而试了若干哼唱检索,都没有结果。
2. 我大概记得一些歌词片段,于是去各种网站搜索。然而结果证明我记忆的片段是错误的。
3. 我“感觉”这是一个日本动画的ED, 于是去搜索了80 90年代引进的日本动画, 以及00-08年流行的日本动画的OP ED,然而没有找到。这个比较巧妙,因为圣少女国内引进过,但是节选了OP和ED。我其实也翻了日版动画,大概看了前几集和后几集的OP ED,万没想到结果是中间的。
4. 我“感觉”动画是跟魔法少女有关,所以翻了翻魔卡少女樱和Marybell的乐集,一无所获。当时其实也过了一遍圣少女的乐集,不知为何漏掉了。
5. 后来放宽了条件,搜了一些类型相似的动画乐集,虽然没找到当前这个,但是意外找到了我的女神里的《優しい心》。这个也是以前突然蹦出来的旋律。同时翻到了同作品里的《願い》,感觉跟要找的相似,然而其实没啥相似,除了都是欢快的曲子。
6. 于是放弃了,能试的都试了,只能随缘了。
7. 后来调整了下思维,想到有没有可能是其他类属性。于是翻了一下邓丽君的日文歌集,甚至《梅兰梅兰我爱你》,当然还是无果。
8. 最后真的是随了缘,重翻了一下圣少女的乐集,竟然找到了。

这个过程里我觉得最有趣的是两点:
一是我记忆里的“感觉”,日本动画, ED, 魔法少女。这样的记忆比曲子本身深刻一些。这也让找曲子更困难了一些。
二是我记忆里的不确定因素,包括旋律歌词。我试想过多种可能的乐器组合,以及歌词韵脚,感觉都有可能。最后也证明我这部分记忆都是不准确的。

2021-04-26

Notes on Color #9: Color Calibration

In January, as part of the preparation for digital painting training, I calibrated my laptop display and my pen display. Yet in April I realized that images look quite different on my laptop, on the pen display, on my phone or on others' devices.

After hours of research, trail and error, I managed to learn more principles and calibrated my hardware and software. Here are some notes:

1. Colorimeters are not spectrometers. Instead of measuring the full (visible) spectrum, the main goal is to simulate a standard observer (with three color receptors), or XYZ values.

2. Due to #1, there are assumptions made here and there to cut down the cost without hurting the quality too much. However an important aspect is the type of monitor (e.g. WLED, WLED+phosphor, GB LED,  RGB LED, OLED etc.).  The chracteristics of each type is diffrent, mostly on the "base spectrum". The calibration may look off if the wrong correction matrix is used. Note that old colorimeters might not support newer display technologies.

3. The default "Photos" app in Windows does not support embeded color profiles in images. I'm now using XnView MP.

4. Chrome (and likely other browsers) usually support embeded color profiles, however it'd be safer to simply convert the image to sRGB when upaloaded to the Web. The reason is the color profile may be stripped or incorrectly processed by the websites.

5. Chrome by default uses the default color profile (for the current monitor) of the system. It might make sense to change it to sRGB.

6. After trying a few calibration tools by the colorimter vendors (e.g. SpyderExpress, i1profiler), I still prefer DisplayCAL. Note that it still makes sense to install the vendor software, such that DsiplayCal may import correction data.

7. According to the author of DisplayCAL, ICC v4 is not necessisarily better than ICC v2 in practice. And v2 is way more comptable for now.

8. It might be necessary to verify and recalibrate the displays every month.

2021-04-02

Notes on Color #8: Idealized Gamut Mask

Continuing with the previous post, in this one I'll try to identify the goal of gamut mapping, and to create an idealized model. 

The Color "Wheel"

A quick word with color wheel before we can proceed.

The color wheel arranges all paint (or device) colors (or more accurately, chromacity) in a hue-chroma system. The modern version is the uniform color system (UCS). I'll use CAM16UCS as an example. Here is the full visible gamut under D65, projected into CAM16UCS.
"top view" of the D65 visible gamut in CAM16UCS.
The color at (0, 0) is white.
The colors have been mapped to sRGB.

"Side view" of the D65 visible gamut in CAM16UCS.
Note the chroma is 0 at the topmost and the bottom-most.
The colors have been mapped to sRGB.


Observe that the top view resembles the the color wheel, but it is nothing like a perfect circle. We could say this is our modern version of the color "wheel", which presents chromacity uniformly on a 2d plane.

I also included a side view here. We can see that the volume of is a irregular cylinder-alike shape. The volumne is not regular in any direction, because our eyes are more sensitive to some wavelengths (green/yellow) than others (blue).

The Idealized Model

James once mentioned that the gamut mask could be used to simulate/achieve color grading. While color grading in general invovles multiple aspects such as contract, black level, details etc., I believe the focus here is color balance/correction.

Look at the following image:



After Figure 6.10 from Dale Purves and R. Beau Lotto's book Why We See What We Do; An Empirical Theory of Vision (2003, revised 2011)
Source: http://www.huevaluechroma.com/111.php

The blue tiles in A and the yellow tiles in B are actually both neutral gray without the context, which can be verified by sampling the RGB value of the pixels. This demonstrates our abilitiy of chromatic adaptation. We have to keep this in mind when paining a scene with tinted light, or "mood".

To simulate this effect, I simply took standard D65 illuminant, then muted ~1/3 visible spectra on the blue end. This resulting test illuminant would appear strongly yellow.
Under this illuminant, S cells won't receive any (reflected) light, while L and M cells are not affected much. We will not see any "real" blue (under D65) colors, but grey (under D65) objects may appear as blue-ish.

Cone cell response curves.
Source: Wikipedia


Under such an illuminant, the visible gamut is reduced, as shown below: (we do not consider self-emitting objects here)
"top view" of the visible gamut under the test illuminant.
Note that it is much smaller than the D65 version, especially the blue part.
The colors have been mapped to sRGB.
"Side view" of the visible gamut under the test illuminant.
Note the chroma is 0 at the bottom-most, but large at the topmost.
The colors have been mapped to sRGB.

Observed that almost all blue/purple fractions are missing, comparing with the D65 gamut.

We are not done yet. Definitely it's not the case where blue-purple colors suddenly disappear while all other colors stay the same. We still need to figure out how colors are shifted.

To do so, we study the Munsell colors (at value of 5) under D65 and the test illuminant. 

Munsell Colors (V=5) under D65, in CAM16UCS.
Black dots indicate colors that are outside of sRGB

Munsell Colors (V=5) under the test illuminant, in CAM16UCS.
Black dots indicate colors that are outside of sRGB.
Munsell Colors (V=2) under the test illuminant, in CAM16UCS.
Black dots indicate colors that are outside of sRGB.

Observations and interpretations:
  1. Only the top half of the original gamut is covered by the test version. All the colors are shifted towards the new "white" under the test illuminant, which appears yellow if compared with D65. Some colors are pushed outside sRGB and some are pulled inside.
  2. The yellow (D65) area (black dot on the top) is very crowded, while the blue (D65) area (blue-green dots on the bottom) is sparse. Remember that chroma and hue reflect wavelength and relative strength of the dominanting spectrum, therefore removing blue-ish spectra has much greater impact on blue-ish colors than yellow-ish colors.
  3. Comparing the V=2 version and the V=5 version. As V increases, the center of the Munsell colors is moving from black toward  the illuminant color. This is actually the black/grey/white value scale under the test illuminant. 
Assuming the standard Munsell colors represents a uniform color wheel, the shifted Munsell colors would work as a modern version of the gamut mask.

Comparing with the Orignial Version

Interestingly, the original triangular gamut mask works in a very similar way:
  • The triangle covers the top-center area of color wheel. (More accurately, it is important that the gask is off-center, not necessarily at the top-center).
  • The center of the mask is for white/neurtal grey in the painting
  • At least one primary color is completely out of the mask, we have to use grey or grey-ish color instead.
  • Consider the color at the center of the mask. When we mix the lighter and dark versions, it naturally ( and roughly) follows the path from black to the illuminant color.
I think these may well explain the color science behind the gamut mask method.

Meanwhile, also note that:
  • It is not (always) true that "all colors in the gamut mask may be obtained by mixing the gamut primaries. Paint mixing is not linear, it is somwhere between additive and subtractive.
  • The shape of the gamut should be more like ellipse, if we want to cover the entire chromacity. However that way it'd be difficult to identifiy primaries or to obtain colors inside the mask.
  • We need to pay attention to the white point as well as the distribution/division of hue & chroma inside the mask, which should not be uniform in general.
These a few points might worth some attention when we are dicussing color theories, but they may be far less important when we are painting in practice.

Final Thoughts

In this post I tried to interpret and extend the gamut mapping method with modern color theories. If you agree with my arguments, please stay skeptical and be aware of my shallow knowledge of color science. I would appreciate critiques.

As I mentioned in the last section, while there are a few issues, the gamut mask method works quite well in practice, as it is indeed supported by the color science. I find it fascinating that someone was able to come up with it in the 1920s, which is even earlier than the first modern CIE color space (in 1931).

I also believe that these "issues" won't affect much in traditional painting. Nothing is really mathematically accurate anyways, artists are indeed free to adjust chrome/hue/value, or to decide the shape of the mask. Besides, in real life we rarely see the whole visible gamut. In fact, I believe color harmony implies bias/limiting the palette/gamut.

Regarding digital versions, it is also true that most of the issues may be overcome with decent art skills. Yet I think it is important to be aware and conscious the issues when using the tool. 

On the other hand, maybe I can improve it by apply the method for my Zorn palette. We'll see.


Appendix: More on Munsell Colors

I'd like to discuss a few experiments on the Munsell colors. These do not conflict with the points above, but they are less interesting, so I'll just briefly talk about them here in the end.

When calculating Munsell colors under a specific illuminant, it is incorrect to simply apply chromatic adaption on the Munsell colors. That would affect models "self-emitting LEDs under the test illuminant". But we want "reflecting objects under the test illuminant". 

To simulate real reflecting objects we have to start with the spectral reflectance. I ended up using colour.XYZ_to_sd. But keep in mind that this can never be perfect. Information is lost when we convert a spectral distribution into a XYZ value. Also different two sets of  spectral distribution may correspond to the same XYZ value, which means they look exactly the same (by the idealized observer).

One interesting question, at first I expected blue colors would appear much darker under the test illuminant, because I removed all blue-ish wavelengths. However it did not turn out like that. I briefly examined the output of XYZ_to_sd, it seems keep a fraction of reflection of red-ish spectra, even for pure blue in sRGB.

It might be interesting to test a spectral distribution database of paints or real life objects.

In the experiment above, I removed the ~1/3 visible spectra on the blue end from D65. Actually I did the same for 1/3 spectra on the red end or in the middle.

Removed ~1/3 visible spectra on the red end.
Reduced the intensity of ~1/3 visible spectra in the middle to 30%

The results are in general similar, but the impact is quite different. The lost of the red-ish spectra did not have much impact, while the middle spectra had huge impact. In fact I only reduced the intensity or middle spectra to 30%, otherwise all the colors will be pushed out of sRGB.

This effect can be easily understood if we examine the cone cell response curves. The right-most 1/3 span has moderate effects on L cells, but not much on M cells. Meanwhile, the middle 1/3 span covers a large fraction of visible & high sensitive ranges of both L and M. 

Notes on Color #7: Revisiting James Gurney's Gamut Mask

Gamut masks, or gamut mapping, is a color managing tool made popular by James Gurney. It is a set of practical instructions, which allows us to easily create a palette of harmonic colors.

James has explained the method in various formats:
I found this method so inspiring when I first learned about it around 2014. Recently it came back to my mind when I started developing the digital Zorn palette, which turned out to work quite well. I decided to revisit the cool method, in the hope of getting better understanding the method and some color therories.

The goal includes:
  • Recognizing the limitation of physical paints.
  • Figuring out an idealized model of the method.
  • Adapting the method for digtal painting.

The Original Method

I'd summarize the original gamut mapping method as the following 3 steps:

  • Start with a color wheel.
  • Maskthe color wheel with a simple shape, typically a triangle.
  • Use only colors in the mask.
This is it. Believing or not, these super simple steps actual work! 

James once mentioned that the method could go back (at least) to the 1920s. He adapted the method from the book The Enjoyment and Use of Color by Walter Sargent.

On the other hand, there is some hidden, ambiguous information that are often overlooked or misinterpreted. This could be well explained by examining the typical digital implementation.

The Typical Digital Version

The gamut mask is available in Krita, which I will examine in details. There are also a few other versions, online, plugins or standalone binaries, which are basically the same.

Gamut Mask in Krita.

In Krita, we start with a HSV (or HSL, HSY) color wheel. For the mask, the user may choose from a few predefined shape, or draw a custom version. In the UI there is a slider where you can adjust value/lightness/luma. More details can be found here.

Well this digital adaption look so natural and intuitive that I didn't have any doubt, until recently.

What Is Wrong? 

The first issue invovles the choice of the color wheel. In previous posts (1, 2) I discussed issues of value/brightness in HSV/HSL/HSY. However for gamut mask, we need something else, namely uniform distribution of the hues.

In the book Color and Light: A Guide for the Realist Painter, James mentioned that the traditional RYB color wheel suffers from uneven distribution of hues. The red-orange-yellow section is too "loose", while the green-blue secction is too "crowded".

Prior to modern color spaces, the Munsell color system was the best hue-chroma-value system that is perceptually uniform. Even today, the Munsell colors are often used to test modern color spaces. It is easy to observe the difference between HSL and CAM16UCS (a modern uniform color system), if we plot the Munsell colors:

Munsell Colors in HSL


Munsell Colors in CAM16UCS

The second issue is about chroma. Note that there is difference between saturation and chroma. Briefly speaking, chroma is independent and absolute, while saturation is relative and depends on hue and/or value.

In the digital version, when we adjust the V/L/Y channel, the H(ue) and S(aturation) channels remain the same. This means chroma would change along. (Well I didn't even mention the poor performance of uniformity in these models, the weird defintion of "saturation" in HSL and the horrendous stretching of chroma in HSY)

In the original version, however, James explicitly mentioned maintaining chroma when mixing colors. Well sometimes he also mentioned intensity or saturation, but I do believe he meant chroma. A solid evidence is that James obtained lighter/darker versions of the base colors by mixing other high-chroma colors, instead of with pure white/black. 

Next, I would justify my arguments by analyzing the idealized model.