GoPiGo 小汽車︰格點圖像算術《色彩空間》時中︰全像術【一】

經由參考眾多『相同形式』與『類似說法』後,

Mathematics of color balance

Color balancing is sometimes performed on a three-component image (e.g., RGB) using a 3×3 matrix. This type of transformation is appropriate if the image was captured using the wrong white balance setting on a digital camera, or through a color filter.

Scaling monitor R, G, and B

In principle, one wants to scale all relative luminances in an image so that objects which are believed to be neutral appear so. If, say, a surface with  R=240 was believed to be a white object, and if 255 is the count which corresponds to white, one could multiply all red values by 255/240. Doing analogously for green and blue would result, at least in theory, in a color balanced image. In this type of transformation the 3×3 matrix is a diagonal matrix.

\left[{\begin{array}{c}R\\G\\B\end{array}}\right]=\left[{\begin{array}{ccc}255/R'_{w}&0&0\\0&255/G'_{w}&0\\0&0&255/B'_{w}\end{array}}\right]\left[{\begin{array}{c}R'\\G'\\B'\end{array}}\right]

where  R G, and  B are the color balanced red, green, and blue components of a pixel in the image;  R' G', and  B' are the red, green, and blue components of the image before color balancing, and  R'_{w} G'_{w}, and  B'_{w} are the red, green, and blue components of a pixel which is believed to be a white surface in the image before color balancing. This is a simple scaling of the red, green, and blue channels, and is why color balance tools in Photoshop and the GIMP have a white eyedropper tool. It has been demonstrated that performing the white balancing in the phosphor set assumed by sRGB tends to produce large errors in chromatic colors, even though it can render the neutral surfaces perfectly neutral.[9]

Scaling X, Y, Z

If the image may be transformed into CIE XYZ tristimulus values, the color balancing may be performed there. This has been termed a “wrong von Kries” transformation.[10][11] Although it has been demonstrated to offer usually poorer results than balancing in monitor RGB, it is mentioned here as a bridge to other things. Mathematically, one computes:

\left[{\begin{array}{c}X\\Y\\Z\end{array}}\right]=\left[{\begin{array}{ccc}X_{w}/X'_{w}&0&0\\0&Y_{w}/Y'_{w}&0\\0&0&Z_{w}/Z'_{w}\end{array}}\right]\left[{\begin{array}{c}X'\\Y'\\Z'\end{array}}\right]

where  X Y, and  Z are the color-balanced tristimulus values;  X_{w} Y_{w}, and  Z_{w} are the tristimulus values of the viewing illuminant (the white point to which the image is being transformed to conform to);  X'_{w} Y'_{w}, and  Z'_{w} are the tristimulus values of an object believed to be white in the un-color-balanced image, and  X' Y', and  Z' are the tristimulus values of a pixel in the un-color-balanced image. If the tristimulus values of the monitor primaries are in a matrix  \mathbf {P} so that:

  \left[{\begin{array}{c}X\\Y\\Z\end{array}}\right]=\mathbf {P} \left[{\begin{array}{c}L_{R}\\L_{G}\\L_{B}\end{array}}\right]

where  L_{R}, L_{G}, and  L_{B} are the un-gamma corrected monitor RGB, one may use:

\left[{\begin{array}{c}L_{R}\\L_{G}\\L_{B}\end{array}}\right]=\mathbf {P^{-1}} \left[{\begin{array}{ccc}X_{w}/X'_{w}&0&0\\0&Y_{w}/Y'_{w}&0\\0&0&Z_{w}/Z'_{w}\end{array}}\right]\mathbf {P} \left[{\begin{array}{c}L_{R'}\\L_{G'}\\L_{B'}\end{array}}\right]

Von Kries’s method

Johannes von Kries, whose theory of rods and three color-sensitive cone types in the retina has survived as the dominant explanation of color sensation for over 100 years, motivated the method of converting color to the LMS color space, representing the effective stimuli for the Long-, Medium-, and Short-wavelength cone types that are modeled as adapting independently. A 3×3 matrix converts RGB or XYZ to LMS, and then the three LMS primary values are scaled to balance the neutral; the color can then be converted back to the desired final color space:[12]

\left[{\begin{array}{c}L\\M\\S\end{array}}\right]=\left[{\begin{array}{ccc}1/L'_{w}&0&0\\0&1/M'_{w}&0\\0&0&1/S'_{w}\end{array}}\right]\left[{\begin{array}{c}L'\\M'\\S'\end{array}}\right]

where  L M, and  S are the color-balanced LMS cone tristimulus values;  L'_{w} M'_{w}, and  S'_{w} are the tristimulus values of an object believed to be white in the un-color-balanced image, and  L' M', and S' are the tristimulus values of a pixel in the un-color-balanced image.

Matrices to convert to LMS space were not specified by von Kries, but can be derived from CIE color matching functions and LMS color matching functions when the latter are specified; matrices can also be found in reference books.[12]

Scaling camera RGB

By Viggiano’s measure, and using his model of gaussian camera spectral sensitivities, most camera RGB spaces performed better than either monitor RGB or XYZ.[9] If the camera’s raw RGB values are known, one may use the 3×3 diagonal matrix:

\left[{\begin{array}{c}R\\G\\B\end{array}}\right]=\left[{\begin{array}{ccc}255/R'_{w}&0&0\\0&255/G'_{w}&0\\0&0&255/B'_{w}\end{array}}\right]\left[{\begin{array}{c}R'\\G'\\B'\end{array}}\right]

and then convert to a working RGB space such as sRGB or Adobe RGB after balancing.

Preferred chromatic adaptation spaces

Comparisons of images balanced by diagonal transforms in a number of different RGB spaces have identified several such spaces that work better than others, and better than camera or monitor spaces, for chromatic adaptation, as measured by several color appearance models; the systems that performed statistically as well as the best on the majority of the image test sets used were the “Sharp”, “Bradford”, “CMCCAT”, and “ROMM” spaces.[13]

General illuminant adaptation

The best color matrix for adapting to a change in illuminant is not necessarily a diagonal matrix in a fixed color space. It has long been known that if the space of illuminants can be described as a linear model with N basis terms, the proper color transformation will be the weighted sum of N fixed linear transformations, not necessarily consistently diagonalizable.[14]

 

小汽車領悟了所謂『白平衡』,不精確的講︰就是『假設』景象中有『白物』,『理論白』定義是『RGB』的『等量』且『最大值』而已!也知這是不足的哩!當真不能簡單設想一張『紅綠藍』圖片 ,其中根本沒有『黑白』乎?它只是納悶為什麼不『直白』耶?★或許這也是 □ ○  之『論述傳統』也!★

聽聞後來曾為『塵埃環境』所苦,一時偶然形成『狹縫』,突見『干涉條紋』哩,有如七彩河流一般!待清洗鏡頭後,不可復見?因此好奇什麼導致『能見不能見』的呢??幾經嘗試終不可得,遂詢之洛水小神龜,得言︰『同調性』難得也☆

雖然借著『水滴、泡泡』容易目睹︰

Example 3 – Thin Film Interference

In this example, we will calculate the colors produced by interference films, such as a soap bubble, or an oil slick on water.  This time, we will use D65 as the illuminant.

The physical situation can be described by illumination from above, passing through a dielectric medium with some index of refraction n1.  As the wave propagates, it meets an interface where the index of refraction changes to a new value n2.  At the interface, part of the original wave is reflected, and part continues into the new medium.  The material n2 is considered to be in a thin layer.  After passing through this thin layer, the wave meets a second interface, where the index of refraction changes from n2 to n3.  Again, part of the incident wave is reflected from the interface, and part continues to propagate.

We will assume that the regions where the index is n1 and n3 are infinite in extent, while the region where the index is n2 is limited to a thin layer, with thickness t.

Some typical indices of refraction of real materials are:
n = 1.000 – Vacuum
n = 1.003 – Air
n = 1.33   – Water
n = 1.44   – Oil
n = 1.50   – Glass

The total reflected wave from the system is a combination of the wave reflected from the first interface (n1 to n2), and the wave reflected from the second interface (n2 to n3).

There may be multiple reflections – e.g. the wave reflected from the second interface will not fully pass through the (now reversed) interface from n2 to n1, rather only part will pass, while some will reflect again and head back to the interface from n2 to n3.  The calculations in ColorPy consider all numbers of multiple reflections, not just a single reflection.

What makes the interesting colors, is that the two waves travel through a different path length, and this results in them being out of phase.  The exact change in phase depends on both the wavelength of the light, the thickness of the layer, and the index of refraction of the layer.  Depending on the specifics, the two waves may constructively interfere, resulting in a large amplitude of the reflected wave, or the waves may destructively interfere, resulting in a small (or zero) amplitude of the reflected wave, or something in between.

Whether the interference is constructive or destructive depends on the wavelength, and for thin films, part of the spectrum will be reduced from destructive interference, and part enhanced from constructive interference, resulting in a significant color shift.

First, consider a soap bubble.  In this situation, material 1 is air, material 2 is a solution of soap in water, while material 3 is air again.  (The inside of the bubble.)  So, n1 = 1.003, n2 = 1.33, and n3 = 1.003.  Calculating the color of the total reflection, with an illuminant of D65, as a function of the thickness of the layer, results in the plot below.  Note that the RGB components oscillate as the thickness is varied.

The phase relationship between the red, green and blue components affects the resulting color.

For the most part, these stay within the displayable range of 0.0 to 1.0, but there are a few places where the red component becomes negative, in the most vivid green regions.  These vivid green colors cannot be properly displayed on the monitor, the true color is more saturated than what is shown.  Most of the other colors can be displayed properly.


Figure 16 – Color of reflections from a soap bubble.  The illuminant is D65.

 

其理說深也深,就是『相位差恆定』 Coherence (physics)

In physics, two wave sources are perfectly coherent if they have a constant phase difference and the same frequency. Coherence is an ideal property of waves that enables stationary (i.e. temporally and spatially constant) interference. It contains several distinct concepts, which are limiting cases that never quite occur in reality but allow an understanding of the physics of waves, and has become a very important concept in quantum physics. More generally, coherence describes all properties of the correlation between physical quantities of a single wave, or between several waves or wave packets.

Interference is nothing more than the addition, in the mathematical sense, of wave functions. A single wave can interfere with itself, but this is still an addition of two waves (see Young’s slits experiment). Constructive or destructive interferences are limit cases, and two waves always interfere, even if the result of the addition is complicated or not remarkable.

When interfering, two waves can add together to create a wave of greater amplitude than either one (constructive interference) or subtract from each other to create a wave of lesser amplitude than either one (destructive interference), depending on their relative phase. Two waves are said to be coherent if they have a constant relative phase. The amount of coherence can readily be measured by the interference visibility, which looks at the size of the interference fringes relative to the input waves (as the phase offset is varied); a precise mathematical definition of the degree of coherence is given by means of correlation functions.

Spatial coherence describes the correlation (or predictable relationship) between waves at different points in space, either lateral or longitudinal.[1] Temporal coherence describes the correlation between waves observed at different moments in time. Both are observed in the Michelson–Morley experiment and Young’s interference experiment. Once the fringes are obtained in the Michelson interferometer, when one of the mirrors is moved away gradually, the time for the beam to travel increases and the fringes become dull and finally are lost, showing temporal coherence. Similarly, if in a double-slit experiment, the space between the two slits is increased, the coherence dies gradually and finally the fringes disappear, showing spatial coherence. In both cases, the fringe amplitude slowly disappears, as the path difference increases past the coherence length.

 

好顯『波性』見『干涉』也︰

Interference (wave propagation)

In physics, interference is a phenomenon in which two waves superpose to form a resultant wave of greater, lower, or the same amplitude. Interference usually refers to the interaction of waves that are correlated or coherent with each other, either because they come from the same source or because they have the same or nearly the same frequency. Interference effects can be observed with all types of waves, for example, light, radio, acoustic, surface water waves or matter waves.

The iridescence of soap bubbles is due to thin-film interference.

 

先之所言『同調性』者,同理矣。『 』調者,『和』也。是假借『聲波』方便聽罷也︰

勇闖新世界︰ W!o《卡夫卡村》變形祭︰品味科學‧教具教材‧ Hi-Jack‧Sonic π 之節拍體驗

你雖尚無小耳朵,蓋無妨矣☆