GoPiGo 小汽車︰格點圖像算術《彩色世界》【顏色ABC】四

若講『色彩空間』就是人類所能『感知』之『顏色』形成的空間。怕是講了也像沒講的吧!科學家依據『紅綠藍三原色說』想將之『量化』,首先得面對『單色光』的『光譜』選擇哩?然後才能作『實驗』,將『測試色』與『 RGB 可調光』成『批配』,逐步完善『標準化』的也︰

Definition of the CIE XYZ color space

CIE RGB color space

The CIE RGB color space is one of many RGB color spaces, distinguished by a particular set of monochromatic (single-wavelength) primary colors.

In the 1920s, W. David Wright[3] and John Guild[4] independently conducted a series of experiments on human sight which laid the foundation for the specification of the CIE XYZ color space. Wright carried out trichromatic color matching experiments with ten observers. Guild actually conducted his experiments with seven observers.

 Gamut of the CIE RGB primaries and location of primaries on the CIE 1931 xy chromaticity diagram.

The experiments were conducted by using a circular split screen (a bipartite field) 2 degrees in diameter, which is the angular size of the human fovea. On one side of the field a test color was projected and on the other side, an observer-adjustable color was projected. The adjustable color was a mixture of three primary colors, each with fixed chromaticity, but with adjustable brightness.

The observer would alter the brightness of each of the three primary beams until a match to the test color was observed. Not all test colors could be matched using this technique. When this was the case, a variable amount of one of the primaries could be added to the test color, and a match with the remaining two primaries was carried out with the variable color spot. For these cases, the amount of the primary added to the test color was considered to be a negative value. In this way, the entire range of human color perception could be covered. When the test colors were monochromatic, a plot could be made of the amount of each primary used as a function of the wavelength of the test color. These three functions are called the color matching functions for that particular experiment.

 The CIE 1931 RGB color matching functions. The color matching functions are the amounts of primaries needed to match the monochromatic test color at the wavelength shown on the horizontal scale.

Although Wright and Guild’s experiments were carried out using various primaries at various intensities, and although they used a number of different observers, all of their results were summarized by the standardized CIE RGB color matching functions {\overline {r}}(\lambda ) {\overline {g}}(\lambda ), and  {\overline {b}}(\lambda ), obtained using three monochromatic primaries at standardized wavelengths of 700 nm (red), 546.1 nm (green) and 435.8 nm (blue). The color matching functions are the amounts of primaries needed to match the monochromatic test primary. These functions are shown in the plot on the right (CIE 1931). Note that {\overline {r}}(\lambda ) and  {\overline {g}}(\lambda ) are zero at 435.8 nm {\overline {r}}(\lambda ) and  {\overline {b}}(\lambda ) are zero at 546.1 nm and  {\overline {g}}(\lambda ) and  {\overline {b}}(\lambda ) are zero at 700 nm, since in these cases the test color is one of the primaries. The primaries with wavelengths 546.1 nm and 435.8 nm were chosen because they are easily reproducible monochromatic lines of a mercury vapor discharge. The 700 nm wavelength, which in 1931 was difficult to reproduce as a monochromatic beam, was chosen because the eye’s perception of color is rather unchanging at this wavelength, and therefore small errors in wavelength of this primary would have little effect on the results.

The color matching functions and primaries were settled upon by a CIE special commission after considerable deliberation.[11] The cut-offs at the short- and long-wavelength side of the diagram are chosen somewhat arbitrarily; the human eye can actually see light with wavelengths up to about 810 nm, but with a sensitivity that is many thousand times lower than for green light. These color matching functions define what is known as the “1931 CIE standard observer”. Note that rather than specify the brightness of each primary, the curves are normalized to have constant area beneath them. This area is fixed to a particular value by specifying that

{\displaystyle \int _{0}^{\infty }{\overline {r}}(\lambda )\,d\lambda =\int _{0}^{\infty }{\overline {g}}(\lambda )\,d\lambda =\int _{0}^{\infty }{\overline {b}}(\lambda )\,d\lambda .}

The resulting normalized color matching functions are then scaled in the r:g:b ratio of 1:4.5907:0.0601 for source luminance and 72.0962:1.3791:1 for source radiance to reproduce the true color matching functions. By proposing that the primaries be standardized, the CIE established an international system of objective color notation.

Given these scaled color matching functions, the RGB tristimulus values for a color with a spectral power distribution {\displaystyle S(\lambda )} would then be given by:

  {\displaystyle R=\int _{0}^{\infty }S(\lambda )\,{\overline {r}}(\lambda )\,d\lambda ,}
{\displaystyle G=\int _{0}^{\infty }S(\lambda )\,{\overline {g}}(\lambda )\,d\lambda ,}
  {\displaystyle B=\int _{0}^{\infty }S(\lambda )\,{\overline {b}}(\lambda )\,d\lambda .}

These are all inner products and can be thought of as a projection of an infinite-dimensional spectrum to a three-dimensional color.

Grassmann’s law

One might ask: “Why is it possible that Wright and Guild’s results can be summarized using different primaries and different intensities from those actually used?” One might also ask: “What about the case when the test colors being matched are not monochromatic?” The answer to both of these questions lies in the (near) linearity of human color perception. This linearity is expressed in Grassmann’s law.

The CIE RGB space can be used to define chromaticity in the usual way: The chromaticity coordinates are r and g where:

{\displaystyle r={\frac {R}{R+G+B}},}
  {\displaystyle g={\frac {G}{R+G+B}}.}

 

由於『RGB』配色會遭遇『負值』,大自然果有『負能量』之光子哉??此所以不得不用『虛擬光譜源』耶!!

Color matching functions

The CIE standard observer color matching functions.

The CIE’s color matching functions  {\overline {x}}(\lambda ) {\overline {y}}(\lambda ) and  {\overline {z}}(\lambda ) are the numerical description of the chromatic response of the observer (described above). They can be thought of as the spectral sensitivity curves of three linear light detectors yielding the CIE tristimulus values X, Y and Z. Collectively, these three functions are known as the CIE standard observer.[10]

Other observers, such as for the CIE RGB space or other RGB color spaces, are defined by other sets of three color-matching functions, and lead to tristimulus values in those other spaces.

Computing XYZ From Spectral Data

Emissive Case

The tristimulus values for a color with a spectral radiance Le,Ω,λ are given in terms of the standard observer by:

  {\displaystyle X=\int _{\lambda }L_{\mathrm {e} ,\Omega ,\lambda }(\lambda )\,{\overline {x}}(\lambda )\,d\lambda ,}
  {\displaystyle Y=\int _{\lambda }L_{\mathrm {e} ,\Omega ,\lambda }(\lambda )\,{\overline {y}}(\lambda )\,d\lambda ,}
  {\displaystyle Z=\int _{\lambda }L_{\mathrm {e} ,\Omega ,\lambda }(\lambda )\,{\overline {z}}(\lambda )\,d\lambda .}

where  \lambda is the wavelength of the equivalent monochromatic light (measured in nanometers), and the standard limits of the integral are {\displaystyle \lambda \in [380,780]}.

The values of X, Y, and Z are bounded if the radiance spectrum Le,Ω,λ is bounded.

Reflective and Transmissive Cases

The reflective and transmissive cases are very similar to the emissive case, with a few differences. The spectral radiance Le,Ω,λ is replaced by the spectral reflectance (or transmittance) S(λ) of the object being measured, multiplied by the spectral power distribution of the illuminant I(λ).

{\displaystyle X={\frac {K}{N}}\int _{\lambda }S(\lambda )\,I(\lambda )\,{\overline {x}}(\lambda )\,d\lambda ,}
  {\displaystyle Y={\frac {K}{N}}\int _{\lambda }S(\lambda )\,I(\lambda )\,{\overline {y}}(\lambda )\,d\lambda ,}
{\displaystyle Z={\frac {K}{N}}\int _{\lambda }S(\lambda )\,I(\lambda )\,{\overline {z}}(\lambda )\,d\lambda ,}

where

{\displaystyle N=\int _{\lambda }I(\lambda )\,{\overline {y}}(\lambda )\,d\lambda ,}

K is a scaling factor (usually 1 or 100), and  \lambda is the wavelength of the equivalent monochromatic light (measured in nanometers), and the standard limits of the integral are  {\displaystyle \lambda \in [380,780]}.

CIE xy chromaticity diagram and the CIE xyY color space

Since the human eye has three types of color sensors that respond to different ranges of wavelengths, a full plot of all visible colors is a three-dimensional figure. However, the concept of color can be divided into two parts: brightness and chromaticity. For example, the color white is a bright color, while the color grey is considered to be a less bright version of that same white. In other words, the chromaticity of white and grey are the same while their brightness differs.

The CIE XYZ color space was deliberately designed so that the Y parameter is a measure of the luminance of a color. The chromaticity of a color is then specified by the two derived parameters x and y, two of the three normalized values being functions of all three tristimulus values X, Y, and Z:

x={\frac {X}{X+Y+Z}}
y={\frac {Y}{X+Y+Z}}
  z={\frac {Z}{X+Y+Z}}=1-x-y

The derived color space specified by x, y, and Y is known as the CIE xyY color space and is widely used to specify colors in practice.

The X and Z tristimulus values can be calculated back from the chromaticity values x and y and the Y tristimulus value:

  {\displaystyle X={\frac {Y}{y}}x,}
  {\displaystyle Z={\frac {Y}{y}}(1-x-y).}

The figure on the right shows the related chromaticity diagram. The outer curved boundary is the spectral locus, with wavelengths shown in nanometers. Note that the chromaticity diagram is a tool to specify how the human eye will experience light with a given spectrum. It cannot specify colors of objects (or printing inks), since the chromaticity observed while looking at an object depends on the light source as well.

Mathematically the colors of the chromaticity diagram occupy a region of the real projective plane.

The chromaticity diagram illustrates a number of interesting properties of the CIE XYZ color space:

  • The diagram represents all of the chromaticities visible to the average person. These are shown in color and this region is called the gamut of human vision. The gamut of all visible chromaticities on the CIE plot is the tongue-shaped or horseshoe-shaped figure shown in color. The curved edge of the gamut is called the spectral locus and corresponds to monochromatic light (each point representing a pure hue of a single wavelength), with wavelengths listed in nanometers. The straight edge on the lower part of the gamut is called the line of purples. These colors, although they are on the border of the gamut, have no counterpart in monochromatic light. Less saturated colors appear in the interior of the figure with white at the center.
  • It is seen that all visible chromaticities correspond to non-negative values of x, y, and z (and therefore to non-negative values of X, Y, and Z).
  • If one chooses any two points of color on the chromaticity diagram, then all the colors that lie in a straight line between the two points can be formed by mixing these two colors. It follows that the gamut of colors must be convex in shape. All colors that can be formed by mixing three sources are found inside the triangle formed by the source points on the chromaticity diagram (and so on for multiple sources).
  • An equal mixture of two equally bright colors will not generally lie on the midpoint of that line segment. In more general terms, a distance on the CIE xy chromaticity diagram does not correspond to the degree of difference between two colors. In the early 1940s, David MacAdam studied the nature of visual sensitivity to color differences, and summarized his results in the concept of a MacAdam ellipse. Based on the work of MacAdam, the CIE 1960, CIE 1964, and CIE 1976 color spaces were developed, with the goal of achieving perceptual uniformity (have an equal distance in the color space correspond to equal differences in color). Although they were a distinct improvement over the CIE 1931 system, they were not completely free of distortion.
  • It can be seen that, given three real sources, these sources cannot cover the gamut of human vision. Geometrically stated, there are no three points within the gamut that form a triangle that includes the entire gamut; or more simply, the gamut of human vision is not a triangle.
  • Light with a flat power spectrum in terms of wavelength (equal power in every 1 nm interval) corresponds to the point (x, y) = (1/3, 1/3).

The CIE 1931 color space chromaticity diagram. The outer curved boundary is the spectral (or monochromatic) locus, with wavelengths shown in nanometers. Note that the colors your screen displays in this image are specified using sRGB, so the colors outside the sRGB gamut are not displayed properly. Depending on the color space and calibration of your display device, the sRGB colors may not be displayed properly either. This diagram displays the maximally saturated bright colors that can be produced by a computer monitor or television set.

The CIE 1931 color space chromaticity diagram rendered in terms of the colors of lower saturation and value than those displayed in the diagram above that can be produced by pigments, such as those used in printing. The color names are from the Munsell color system.

 

本就晨昏恐遇『色度』不同乎!!??

Chromaticity

Chromaticity is an objective specification of the quality of a color regardless of its luminance. Chromaticity consists of two independent parameters, often specified as hue (h) and colorfulness (s), where the latter is alternatively called saturation, chroma, intensity,[1] or excitation purity.[2][3] This number of parameters follows from trichromacy of vision of most humans, which is assumed by most models in color science.

The CIE 1931 xy chromaticity space, also showing the chromaticities of black-body light sources of various temperatures, and lines of constant correlated color temperature

 

如何言人世間有人有

四色視覺

四色視覺英語:Tetrachromacy)是指生物體擁有四種獨立的感光通道,或指眼球中有四種感色的視錐細胞(較人類多出感應紫外線錐狀細胞),大部分鳥類具有此種特徵。一般人類所繪製出的圖案對四色視覺者可能是難以理解的。

梅花雀視錐細胞的感光響應曲線,其感光範圍從可見光到紫外線[1]

 

的呀??!!

且權充稍補足 ColorPy 文本而已矣☆

Fundamentals – Mapping spectra to three-dimensional color values

We are interested in working with physical descriptions of light spectra, that is, functions of intensity vs. wavelength.  However, color is perceived as a three-dimensional quantity, as there are three sets of color receptors in the eye, which respond approximately to red, green and blue light.  So how do we reduce a function of intensity vs. wavelength to a three-dimensional value?

This fundamental step is done by integrating the intensity function with a set of three matching functions.  The standard matching functions were defined by the Commission Internationale de l’Eclairage (CIE), based on experiments with viewers matching the color of single wavelength lights.  The matching functions generally used in computer graphics are those developed in 1931, which used a 2 degree field of view.  (There is also a set of matching functions developed in 1964, covering a field of view of 10 degrees, but the larger field of view does not correspond to typical conditions in viewing computer graphics.)  So the mapping is done as follows:

X = ∫ I (λ) * CIE-X (λ) * dλ
Y = ∫ I (λ) * CIE-Y (λ) * dλ
Z = ∫ I (λ) * CIE-Z (λ) * dλ

where I (λ) is the spectrum of light intensity vs. wavelength, and CIE-X (λ), CIE-Y (λ) and CIE-Z (λ) are the matching functions.  The CIE matching functions are defined over the interval of 360 nm to 830 nm, and are zero for all wavelengths outside this interval, so these are the bounds for the integrals.

So what do these matching functions look like?  Let’s take a look at a plot (made with ColorPy, of course.)


Figure 1 – The 1931 CIE XYZ matching functions.

This plot shows the three matching functions vs. wavelength.  The colors underneath the curve, at each wavelength, are the (approximate) colors that the human eye will perceive for a pure spectral line at that wavelength, of constant intensity.  The apparent brightness of the color at each wavelength indicates how strongly the eye perceives that wavelength – the intensity for each wavelength is the same.  (The next section will explain how we get the RGB values for the colors.)

Each of the three plots was generated via colorpy.plots.spectrum_subplot (spectrum), where spectrum is the value of the matching function vs. wavelength.

All three of the matching functions are zero or positive everywhere.  Since the light intensity at any wavelength is never negative, this means that the resulting XYZ color values are never negative.  Also, the Y matching function corresponds exactly to the luminous efficiency of the eye – the eye’s response to light of constant luminance.  (These facts are some of the reasons that make this particular set of matching functions so useful.)

So now we can map a spectrum of intensity vs. wavelength into a three-dimensional value.  Before we consider how to convert this into an RGB color value that we can draw, we will first discuss some typical scaling operations on XYZ colors.

Often, it is useful to consider the ‘chromaticity’ of a color, that is, the hue and saturation, independent of the intensity.  This is typically done by scaling the XYZ values so that their sum is 1.0.  The resulting scaled values are conventionally written as lower case letters x,y,z.  With this scaling, x+y+z = 1.0.  The chromaticity can be specified by the resulting x and y values, and the z component can be reconstructed as z = 1.0 – x – y.  It is also common to specify colors with their chromaticity (x and y), as well as the total brightness (Y).  Occasionally, one also wants to scale an XYZ color so that the resulting Y value is 1.0.

ColorPy represents XYZ colors (and other types of colors) as three-component vectors.  There are some ‘constructor’ like functions to create such arrays, and perform these kinds of scaling:

colorpy.colormodels.xyz_color (x, y, z = None)
colorpy.colormodels.xyz_normalize (xyz)
colorpy.colormodels.xyz_color_from_xyY (x, y, Y)
colorpy.colormodels.xyz_normalize_Y1 (xyz)

Notice that color types are generally specified in ColorPy with lower case letters, as this is more readable.  (I.e., xyz_color instead of XYZ_color.)  The user must keep track of the particular normalization that applies in each situation.

Fundamentals – Converting XYZ colors to RGB colors

So how do we convert one of these XYZ colors to an RGB color that I can draw on my computer?

The short answer, is to call colorpy.colormodels.irgb_from_xyz (xyz), where xyz is the XYZ color vector.  This will return a three element integer vector, with each component in the range 0 – 255.  There is also a function colorpy.colormodels.irgb_string_from_xyz (xyz) that will return a hex string, such as ‘#FF0000’ for red.

There are several subtleties and approximations in the behavior of these functions, which are important to understand what is happening.

The first step in the conversion, is to convert the XYZ color to a ‘linear’ RGB color.  By ‘linear’, we mean that the light intensity is proportional to the numerical color values.  ColorPy represents such linear RGB values as floats, with the nominal range of 0.0 – 1.0 covering the range of intensity that the monitor display can produce.  (This implies an assumption as to the physical brightness of the display.)  The conversion from XYZ to linear RGB is done by multiplication by a 3×3 element array.  So, which array to use?  The specific values of the array depend on the physical display in question, specifically the chromaticities of the monitor phosphors.  Not all displays have the exact same red, green and blue monitor primaries, and so any conversion matrix cannot apply to all displays.  This can be a considerable complication, but fortunately, there is a specification of monitor chromaticities that we can assume, part of the sRGB standard, and are likely to be a close match to most actual displays.  ColorPy uses this assumption by default, although you can change the assumed monitor chromaticities to nearly anything you like.

So for now, let’s assume the standard sRGB chromaticities, which gives us the correct 3×3 matrix, and so we can convert our XYZ colors to linear RGB colors.

We then come to the next obstacle…  The RGB values that we get from this process are often out of range – meaning that they are either greater than 1.0, or even that they are negative!  The first case is fairly straightforward, it means that the color is too bright for the display.  The second case means that the color is too saturated and vivid for the display.  The display must compose all colors from some combination of positive amounts of the colors of its red, green and blue phosphors.  The colors of these phosphors are not perfectly saturated, they are washed out, mixed with white, to some extent.  So not all colors can be displayed accurately.  As an example, the colors of pure spectral lines, all have some negative component.  Something must be done to put these values into the 0.0 – 1.0 range that can actually be displayed, known as color clipping.

In the first case, values larger than 1.0, ColorPy scales the color so that the maximum component is 1.0.  This reduces the brightness without changing the chromaticity.  The second case requires some change in chromaticity.  By default, ColorPy will add white to the color, just enough to make all of the components non-negative.  (You can also have ColorPy clamp the negative values to zero.  My personal, qualitative, assessment is that adding white produces somewhat better results.  There is also the potential to develop a better clipping function.)

So now we have linear RGB values in the range 0.0 – 1.0.  The next subtlety in the conversion process, is that the intensity of colors on the display is not simply proportional to the color values given to the hardware.  This situation is known as ‘gamma correction’, and is particularly significant for CRT displays.  The voltage on the electron gun in the CRT display is proportional to the RGB values given to the hardware to display, but the intensity of the resulting light is *not* proportional to this voltage, in fact the relationship is a power law.  The particular correction for this depends on the physical display in question.  LCD displays add another complication, as it is not clear (at least to me) what the correct conversion is in this case.  Again, we rely on the sRGB standard to decide what to do.  That standard assumes a physical ‘gamma’ exponent of about 2.2, and ColorPy applies this correction by default.  You can change this to a different exponent if you like.

The final step after gamma correction, is to convert the RGB components from the range 0.0 – 1.0 to 0 – 255, which is the typical range needed to pass to the hardware.  This is done with simple scaling and rounding.  The final result of all of these conversions, RGB color values in the range 0 – 255, is referred to as an irgb_color.  This is the color type that can be passed to drawing functions.

Summarizing of these conversions, with the functions that ColorPy uses internally:

colorpy.colormodels.rgb_from_xyz (xyz) – Converts an XYZ color to a linear RGB color, with components in the nominal range 0.0 – 1.0, but possibly out of range (greater than 1.0, or negative).  The resulting linear RGB color cannot be directly passed to drawing functions.

colorpy.colormodels.irgb_from_rgb (rgb) – Converts a linear RGB color in the nominal range 0.0 – 1.0 to a displayable irgb color, definitely in the range 0 – 255.  Color clipping may be applied (intensity as well as chromaticity), and gamma correction is accounted for.  This result can be passed to drawing functions.


With all of this, let’s plot some real colors.  First, consider the pure spectral lines – that is, spectra that are all black (zero intensity), except at a single wavelength.  We consider all the wavelengths from 360 nm to 830 nm, which covers the range of human vision (and the range of the CIE XYZ matching functions.)

The two-part plot below shows the result.  The top section, shows the best colors that ColorPy can draw for each wavelength.  The amount of light intensity for each wavelength is the same.  But since the human eye has different sensitivity to different wavelengths, the apparent brightness looks different for different colors.  For example, the color for 750 nm is quite dark, while the color for 550 nm is quite bright.  They represent lines with the same physical luminance, however.  The bottom section shows the linear RGB values corresponding to each wavelength.  You can see that there are negative RGB values on this plot.  In fact, there is a negative component at every wavelength – none of the pure spectral lines can be displayed with full saturation.  (The overall intensity scale is arbitrary, and has been chosen so that the largest RGB component for any wavelength is 1.0.)


Figure 2 – RGB values for the pure spectral lines.

This specific plot was made with colorpy.plots.visible_spectrum_plot (), and the real work was done with colorpy.plots.color_vs_param_plot (param_list, rgb_colors, title, filename, tight=False, plotfunc=pylab.plot, xlabel='param', ylabel='RGB Color').  This function accepts two lists, one of an arbitrary parameter (wavelength in this case), and one of linear RGB colors.  (The two lists must be of the same size.)  You also must supply a title and filename for the plot.  Optional arguments include a request that the x-axis be ‘tightened’ to only include the range of the parameters, a different plotting function from the default, and different labels for the axes.  This is a very handy function, useful for many other plots besides this one.

You can see that there are negative RGB values for these colors, and those actually drawn have been clipped to something displayable.

Another way to understand the limited color gamut (range of displayable colors) of physical displays, is to consider the ‘shark fin’ CIE chromaticity diagram.  On this plot, we draw the chromaticities of the pure spectral lines.  These trace out a fin shaped region.  The low wavelength colors start at the lower left corner of the fin, and as the wavelength increases, moves up on the plot towards green, and then down and to the right towards yellow and red.  The longest wavelength corresponds to the red corner at the far right.  The straight line connecting the long wavelength red to the short wavelength blue is not composed of pure spectral lines, rather these ‘purples’ are a linear combination of the extreme red and blue colors.  The outer boundary of this diagram represents the spectrally pure colors.  Just inside this boundary, we draw the best color match for each wavelength.

The triangle inside the fin represents the range (gamut) of colors that the physical display can show.  The vertices labeled Red, Green and Blue represent the chromaticities of the monitor primaries, and the point labeled White represents the white point with all primaries at full strength.  (This plot assumes the standard sRGB primaries and white point.)  The points inside the inner triangle are the only colors that the display can render accurately.  (This figure could use a little work.  It would be nice to label the outer boundary of the fin with the corresponding wavelength.)  The points outside the inner triangle are colors that must be approximated.  (Points outside the outer ‘fin’ do not correspond to any color at all.)

You can see that the standard monitor is much more limited in displaying greens than blues and reds.  If someone is able to invent a much purer green colored phosphor, with low persistence so it is suitable for animations and hence real displays, then the world of computer graphics will get significantly more richly colored!  Also notice that there is no possible set of of three monitor phosphor chromaticities that can cover the entire visible gamut.  For any three points inside the ‘fin’, the enclosed triangle must necessarily exclude some of the pure spectral colors, even if the monitor phosphors were perfectly spectrally pure.


Figure 3 – CIE chromaticity diagram of the visible gamut.
Colors inside the inner triangle can be accurately drawn on the display, points outside (but inside the fin) must be approximated.

This figure is drawn with colorpy.plots.shark_fin_plot().  This is kind of a specialized figure, probably not that useful for other things.

 

 

 

 

 

 

 

 

 

GoPiGo 小汽車︰格點圖像算術《彩色世界》【顏色ABC】三

『知覺』非『覺知』︰

Perception

Development of theories of color vision

 

Although Aristotle and other ancient scientists had already written on the nature of light and color vision, it was not until Newton that light was identified as the source of the color sensation. In 1810, Goethe published his comprehensive Theory of Colors in which he ascribed physiological effects to color that are now understood as psychological.

In 1801 Thomas Young proposed his trichromatic theory, based on the observation that any color could be matched with a combination of three lights. This theory was later refined by James Clerk Maxwell and Hermann von Helmholtz. As Helmholtz puts it, “the principles of Newton’s law of mixture were experimentally confirmed by Maxwell in 1856. Young’s theory of color sensations, like so much else that this marvelous investigator achieved in advance of his time, remained unnoticed until Maxwell directed attention to it.”[10]

At the same time as Helmholtz, Ewald Hering developed the opponent process theory of color, noting that color blindness and afterimages typically come in opponent pairs (red-green, blue-orange, yellow-violet, and black-white). Ultimately these two theories were synthesized in 1957 by Hurvich and Jameson, who showed that retinal processing corresponds to the trichromatic theory, while processing at the level of the lateral geniculate nucleus corresponds to the opponent theory.[11]

In 1931, an international group of experts known as the Commission internationale de l’éclairage (CIE) developed a mathematical color model, which mapped out the space of observable colors and assigned a set of three numbers to each.

 

『客觀』逢『主觀』︰

Color in the eye

 Normalized typical human cone cell responses (S, M, and L types) to monochromatic spectral stimuli

The ability of the human eye to distinguish colors is based upon the varying sensitivity of different cells in the retina to light of different wavelengths. Humans are trichromatic—the retina contains three types of color receptor cells, or cones. One type, relatively distinct from the other two, is most responsive to light that is perceived as blue or blue-violet, with wavelengths around 450 nm; cones of this type are sometimes called short-wavelength cones, S cones, or blue cones. The other two types are closely related genetically and chemically: middle-wavelength cones, M cones, or green cones are most sensitive to light perceived as green, with wavelengths around 540 nm, while the long-wavelength cones, L cones, or red cones, are most sensitive to light is perceived as greenish yellow, with wavelengths around 570  nm.

Light, no matter how complex its composition of wavelengths, is reduced to three color components by the eye. Each cone type adheres to the Principle of Univariance, which is that each cone’s output is determined by the amount of light that falls on it over all wavelengths. For each location in the visual field, the three types of cones yield three signals based on the extent to which each is stimulated. These amounts of stimulation are sometimes called tristimulus values.

The response curve as a function of wavelength varies for each type of cone. Because the curves overlap, some tristimulus values do not occur for any incoming light combination. For example, it is not possible to stimulate only the mid-wavelength (so-called “green”) cones; the other cones will inevitably be stimulated to some degree at the same time. The set of all possible tristimulus values determines the human color space. It has been estimated that humans can distinguish roughly 10 million different colors.[9]

The other type of light-sensitive cell in the eye, the rod, has a different response curve. In normal situations, when light is bright enough to strongly stimulate the cones, rods play virtually no role in vision at all.[12] On the other hand, in dim light, the cones are understimulated leaving only the signal from the rods, resulting in a colorless response. (Furthermore, the rods are barely sensitive to light in the “red” range.) In certain conditions of intermediate illumination, the rod response and a weak cone response can together result in color discriminations not accounted for by cone responses alone. These effects, combined, are summarized also in the Kruithof curve, that describes the change of color perception and pleasingness of light as function of temperature and intensity.

 

『科學』未窮盡︰

Color in the brain

The visual dorsal stream (green) and ventral stream (purple) are shown. The ventral stream is responsible for color perception.

While the mechanisms of color vision at the level of the retina are well-described in terms of tristimulus values, color processing after that point is organized differently. A dominant theory of color vision proposes that color information is transmitted out of the eye by three opponent processes, or opponent channels, each constructed from the raw output of the cones: a red–green channel, a blue–yellow channel, and a black–white “luminance” channel. This theory has been supported by neurobiology, and accounts for the structure of our subjective color experience. Specifically, it explains why humans cannot perceive a “reddish green” or “yellowish blue”, and it predicts the color wheel: it is the collection of colors for which at least one of the two color channels measures a value at one of its extremes.

The exact nature of color perception beyond the processing already described, and indeed the status of color as a feature of the perceived world or rather as a feature of our perception of the world – a type of qualia – is a matter of complex and continuing philosophical dispute.

 

仰賴『法則』觀︰

Grassmann’s law (optics)

In optics, Grassmann’s law is an empirical result about human color perception: that chromatic sensation can be described in terms of an effective stimulus consisting of linear combinations of different light colors. It was discovered by Hermann Grassmann.

Statement

Grassmann expressed his law with respect to a circular arrangement of spectral colors in this 1853 illustration.[1]

An early statement of law, attributed to Grassmann, is:[2]

If two simple but non-complementary spectral colors be mixed with each other, they give rise to the color sensation which may be represented by a color in the spectrum lying between both and mixed with a certain quantity of white.

Modern interpretation

If a test color is the combination of two other colors, then in a matching experiment based on mixing primary light colors, an observer’s matching value of each primary will be the sum of the matching values for each of the other test colors when viewed separately.

In other words, if beam 1 and 2 are the initial colors, and the observer chooses (R_{1},G_{1},B_{1}) as the strengths of the primaries that match beam 1 and (R_{2},G_{2},B_{2}) as the strengths of the primaries that match beam 2, then if the two beams were combined, the matching values will be the sums of the components. Precisely, they will be  (R,G,B), where:

R=R_{1}+R_{2}\,
G=G_{1}+G_{2}\,
B=B_{1}+B_{2}\,

Grassmann’s law can be expressed in general form by stating that for a given color with a spectral power distribution  I(\lambda) the RGB coordinates are given by:

  R=\int _{0}^{\infty }I(\lambda )\,{\bar r}(\lambda )\,d\lambda
  G=\int _{0}^{\infty }I(\lambda )\,{\bar g}(\lambda )\,d\lambda
  B=\int _{0}^{\infty }I(\lambda )\,{\bar b}(\lambda )\,d\lambda

Observe that these are linear in  I; the functions  {\bar r}(\lambda ),{\bar g}(\lambda ),{\bar b}(\lambda ) are the color matching functions with respect to the chosen primaries.

 

數字聯想苦︰

Tristimulus values

 The normalized spectral sensitivity of human cone cells of short-, middle- and long-wavelength types.

The human eye with normal vision has three kinds of cone cells, which sense light, with spectral sensitivity peaks in short (S, 420 nm440 nm), middle (M, 530 nm540 nm), and long (L, 560 nm580 nm) wavelengths. These cone cells underlie human color perception under medium- and high-brightness conditions (in very dim light, color vision diminishes, and the low-brightness, monochromatic “night-vision” receptors, called rod cells, take over). Thus, three parameters, corresponding to levels of stimulus of the three types of cone cells, can in principle describe any color sensation. Weighting a total light power spectrum by the individual spectral sensitivities of the three types of cone cells gives three effective stimulus values; these three values make up a tristimulus specification of the objective color of the light spectrum. The three parameters, denoted S, M, and L, can be indicated using a 3-dimensional space, called LMS color space, which is one of many color spaces which have been devised to help quantify human color vision.

A color space maps a range of physically produced colors (from mixed light, pigments, etc.) to an objective description of color sensations registered in the eye, typically in terms of tristimulus values, but not usually in the LMS space defined by the cone spectral sensitivities. The tristimulus values associated with a color space can be conceptualized as amounts of three primary colors in a tri-chromatic additive color model. In some color spaces, including LMS and XYZ spaces, the primary colors used are not real colors, in the sense that they cannot be generated with any light spectrum.

The CIE XYZ color space encompasses all color sensations that an average person can experience. That is why CIE XYZ (Tristimulus values) is a device invariant color representation.[5] It serves as a standard reference against which many other color spaces are defined. A set of color-matching functions, like the spectral sensitivity curves of the LMS space but not restricted to be nonnegative sensitivities, associates physically produced light spectra with specific tristimulus values.

Consider two light sources made up of different mixtures of various wavelengths. Such light sources may appear to be the same color; this effect is called metamerism. Such light sources have the same apparent color to an observer when they produce the same tristimulus values, no matter what the spectral power distributions of the sources are.

Most wavelengths stimulate two or all three types of cone cell, because the spectral sensitivity curves of the three types of cone cells overlap. Certain tristimulus values are thus physically impossible (for instance LMS tristimulus values that are non-zero for the M component, and zero for both L and S). Furthermore, LMS tristimulus values for pure spectral colors would, in any normal trichromatic additive color space (e.g. RGB color spaces), imply negative values for at least one of the three primaries, since the chromaticity would be outside the color triangle defined by the primary colors. To avoid these negative RGB values, and to have one component that describes the perceived brightness, “imaginary” primary colors and corresponding color-matching functions have been formulated. The resulting tristimulus values are defined by the CIE 1931 color space, in which they are denoted X, Y, and Z.[6] In XYZ space, all combinations of nonnegative coordinates are meaningful, but many such as the primary locations [1, 0, 0], [0, 1, 0], and [0, 0, 1] correspond to imaginary colors outside the space of possible LMS coordinates; imaginary colors do not correspond to any spectral distribution of wavelengths, so have no physical reality.

Meaning of X, Y and Z

When judging the relative luminance (brightness) of different colors in well-lit situations, humans tend to perceive light within the green parts of the spectrum as brighter than red or blue light of equal power. The luminosity function that describes the perceived brightnesses of different wavelengths is thus roughly analogous to the spectral sensitivity of M cones.

The CIE model capitalises on this fact by defining Y as luminance. Z is quasi-equal to blue stimulation, or the S cone response, and X is a mix (a linear combination) of cone response curves chosen to be nonnegative. The XYZ tristimulus values are thus analogous to, but different from, the LMS cone responses of the human eye. Defining Y as luminance has the useful result that for any given Y value, the XZ plane will contain all possible chromaticities at that luminance.

The unit of the tristimulus values X, Y, and Z is often arbitrarily chosen so that Y = 1 or Y = 100 is the brightest white that a color display supports. The corresponding whitepoint values for X and Z can then be inferred using the standard illuminants.

A comparison between a typical normalised M cone’s spectral sensitivity and the CIE 1931 luminosity function for a standard observer in photopic vision.

CIE standard observer

Due to the distribution of cones in the eye, the tristimulus values depend on the observer’s field of view. To eliminate this variable, the CIE defined a color-mapping function called the standard (colorimetric) observer, to represent an average human’s chromatic response within a 2° arc inside the fovea. This angle was chosen owing to the belief that the color-sensitive cones resided within a 2° arc of the fovea. Thus the CIE 1931 Standard Observer function is also known as the CIE 1931 2° Standard Observer. A more modern but less-used alternative is the CIE 1964 10° Standard Observer, which is derived from the work of Stiles and Burch,[7] and Speranskaya.[8]

For the 10° experiments, the observers were instructed to ignore the central 2° spot. The 1964 Supplementary Standard Observer function is recommended when dealing with more than about a 4° field of view. Both standard observer functions are discretized at 5 nm wavelength intervals from 380 nm to 780 nm and distributed by the CIE.[9] All corresponding values have been calculated from experimentally obtained data using interpolation. The standard observer is characterized by three color matching functions.

The derivation of the CIE standard observer from color matching experiments is given below, after the description of the CIE RGB space.

Color matching functions

The CIE’s color matching functions  {\overline {x}}(\lambda ) {\overline {y}}(\lambda ) and {\overline {z}}(\lambda ) are the numerical description of the chromatic response of the observer (described above). They can be thought of as the spectral sensitivity curves of three linear light detectors yielding the CIE tristimulus values X, Y and Z. Collectively, these three functions are known as the CIE standard observer.[10]

Other observers, such as for the CIE RGB space or other RGB color spaces, are defined by other sets of three color-matching functions, and lead to tristimulus values in those other spaces.

The CIE standard observer color matching functions.

 

隔靴搔癢難︰

RGB color model

The RGB color model is an additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green and blue.

The main purpose of the RGB color model is for the sensing, representation and display of images in electronic systems, such as televisions and computers, though it has also been used in conventional photography. Before the electronic age, the RGB color model already had a solid theory behind it, based in human perception of colors.

RGB is a device-dependent color model: different devices detect or reproduce a given RGB value differently, since the color elements (such as phosphors or dyes) and their response to the individual R, G and B levels vary from manufacturer to manufacturer, or even in the same device over time. Thus a RGB value does not define the same color across devices without some kind of color management.

Typical RGB input devices are color TV and video cameras, image scanners, and digital cameras. Typical RGB output devices are TV sets of various technologies (CRT, LCD, plasma, OLED, Quantum-Dots etc.), computer and mobile phone displays, video projectors, multicolor LED displays and large screens such as JumboTron. Color printers, on the other hand are not RGB devices, but subtractive color devices (typically CMYK color model).

This article discusses concepts common to all the different color spaces that use the RGB color model, which are used in one implementation or another in color image-producing technology.

A representation of additive color mixing. Projection of primary color lights on a white screen shows secondary colors where two overlap; the combination of all three of red, green and blue in equal intensities makes white.

A representation of additive color mixing. Projection of primary color lights on a white screen shows secondary colors where two overlap; the combination of all three of red, green and blue in equal intensities makes white.

History of RGB color model theory and usage

The RGB color model is based on the Young–Helmholtz theory of trichromatic color vision, developed by Thomas Young and Hermann Helmholtz in the early to mid nineteenth century, and on James Clerk Maxwell‘s color triangle that elaborated that theory (circa 1860).

Early color photographs
A bow made of tartan ribbon. The center of the bow is round, made of piled loops of ribbon, with two pieces of ribbon attached underneath, one extending at an angle to the upper left corner of the photograph and another extending to the upper right. The tartan colors are faded, in shades mostly of blue, pink, maroon and white; the bow is set against a background of mottled olive.
The first permanent color photograph, taken by J.C. Maxwell in 1861 using three filters, specifically red, green, and violet-blue.
A large color photograph abutting (to its right) a column of three stacked black-and-white versions of the same picture. Each of the three smaller black-and-white photos are slightly different, due to the effect of the color filter used. Each of the four photographs differ only in color and depict a turbaned and bearded man, sitting in the corner an empty room, with an open door to his right and a closed door to his left. The man is wearing an ornate full-length blue robe trimmed with a checkered red-and-black ribbon. The blue fabric is festooned with depictions of stems of white, purple, and blue flowers. He wears an ornate gold belt, and in his left hand he holds a gold sword and scabbard. Under his right shoulder strap is a white aiguillette; attached to his robe across his upper chest are four multi-pointed badges of various shapes, perhaps military or royal decorations.
A photograph of Mohammed Alim Khan (1880–1944), Emir of Bukhara, taken in 1911 by Sergey Prokudin-Gorsky using three exposures with blue, green, and red filters.

 

『體驗』人『自明』☆★

pi@raspberrypi:~ $ ipython3 --pylab
Python 3.4.2 (default, Oct 19 2014, 13:31:11) 
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg

In [1]: import colorpy.misc

In [2]: 原色 = [
   ...: '#000000',
   ...: '#FF0000',
   ...: '#00FF00',
   ...: '#0000FF',
   ...: '#FFFF00',
   ...: '#FF00FF',
   ...: '#00FFFF',
   ...: '#FFFFFF'
   ...:  ]

In [3]: 原色名 = [ 'Black', 'Red', 'Green', 'Blue', 'Yellow', 'Magenta', 'Cyan', 'White' ]

In [4]: colorpy.misc.colorstring_patch_plot (原色, 原色名, 'Primary Colors', 'primary', num_across=4)
Saving plot primary

In [5]: 

 

 

 

 

 

 

 

 

 

 

 

GoPiGo 小汽車︰格點圖像算術《彩色世界》【顏色ABC】二

Mark Kness 先生寫作『顏色派』

ColorPy

Physical color calculations in Python.

More documentation is currently at http://markkness.net/colorpy/ColorPy.html.


A taste of the plots that ColorPy can create: RGB values for the pure spectral lines.

Version 0.1.1. Changes from 0.1.0: Various things I did on my local machine. A better shark fin plot, for example. Now on GitHub!

Version 0.1.0. I had this hosted at http://markkness.net (and still do) but GitHub is a better place for it now.

 

這時仍喜派生二 Python2 。簡單準備環境後︰

sudo pip install scipy
sudo pip3 install scipy

sudo pip install numpy
sudo pip3 install numpy

sudo apt-get install python-matplotlib python3-matplotlib
sudo apt-get install python-zmq python3-zmq

sudo apt-get install ipython ipython3

 

sudo pip install colorpy 可安裝也。不過作者偏好派生三 Python3 ,嚐試閱讀程式碼,欣聞新版開始支援派生三

git clone https://github.com/markkness/ColorPy.git

 

依理驗證派生二與三︰

Download ColorPy

Binary distribution for Windows (32-bit):    ColorPy-0.1.0.win32.exe

Source distribution for Windows:    ColorPy-0.1.0 zip

Source distribution for Linux:    ColorPy-0.1.0 tarball

Installation:

If you are installing from the Windows binary distribution, all you need to do is double-click the executable, and follow the installation prompts.  Otherwise, you must first unpack the distribution, and then install.

Unpacking the source distributions:

Windows –
Unzip the .zip distribution. Recent versions of Windows (XP or later), will unpack the directory automatically, you can simply enter the directory in Windows Explorer. You will probably need to copy the uncompressed files into another directory.

Linux –
The distribution is a compressed tar archive, uncompress it as follows:

gunzip -c colorpy-0.1.0.tar.gz | tar xf -
cd colorpy-0.1.0

Installing from the source distribution:

From the directory in which the files are unpacked, run:

python setup.py install

It is possible that you may need to supply a path to the Python executable.  You will probably need administrator privileges to do this.  This should complete the installation.

After downloading and installing, I recommend that you run the test cases, and then create the sample figures.  These will provide a check that the module is working correctly.

import colorpy.test
colorpy.test.test()

This will run all the test cases.

import colorpy.figures
colorpy.figures.figures()

This will generate the sample figures (typically .png files), including all those in this documentation, as well as several others.

 

無奈二、三『套件庫』結構不同調,還是二行、三不行?欲改一時不知下手處!左瞧右看夢昧求,忽爾靈感來?莫睡且試誤︰

pi@raspberrypi:~ more /usr/local/lib/python3.4/dist-packages/colorpy/__init__.py  ''' __init__.py  ColorPy is a Python package to convert physical descriptions of light:     spectra of light intensity vs. wavelength - into RGB colors that can     be drawn on a computer screen.     It provides a nice set of attractive plots that you can make of such     spectra, and some other color related functions as well.  License:  Copyright (C) 2008 Mark Kness  Author - Mark Kness - mkness@alumni.utexas.net  This file is part of ColorPy.  ColorPy is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  ColorPy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public License along with ColorPy.  If not, see <http://www.gnu.org/licenses/>. '''  # This file only needs to exist to indicate that this is a package.  # 添加兩行。 import sys sys.path.append('/usr/local/lib/python3.4/dist-packages/colorpy/') pi@raspberrypi:~ 

 

曙光突現前!

pi@raspberrypi:~ $ ipython3 --pylab
Python 3.4.2 (default, Oct 19 2014, 13:31:11) 
Type "copyright", "credits" or "license" for more information.

IPython 2.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg

In [1]: import colorpy.plots

In [2]: colorpy.plots.visible_spectrum_plot ()
Saving plot VisibleSpectrum

In [3]: colorpy.plots.cie_matching_functions_plot()
Saving plot CIEXYZ_Matching

In [4]: 鯊魚翅 = colorpy.plots.shark_fin_plot ()
Saving plot ChromaticityDiagram

In [5]:

 

 

 

 

恍惚神明助☆

 

 

 

 

 

 

 

 

GoPiGo 小汽車︰格點圖像算術《彩色世界》【顏色ABC】 一

絕代佳人何其美?顏值高又 顏色好!古初造字存意指,

樂天顏色』甚易曉︰

長恨歌‧白居易

漢皇重色思傾國,御宇多年求不得。
楊家有女初長成,養在深閨人未識。
天生麗質難自棄,一朝選在君王側。
回眸一笑百媚生,六宮粉黛無顏色。
春寒賜浴華清池,溫泉水滑洗凝脂。
侍兒扶起嬌無力,始是新承恩澤時。
雲鬢花顏金步搖,芙蓉帳暖度春宵。
春宵苦短日高起,從此君王不早朝。
承歡侍宴無閑暇,春從春遊夜專夜。
後宮佳麗三千人,三千寵愛在一身。
金屋妝成嬌侍夜,玉樓宴罷醉和春。
姊妹弟兄皆列土,可憐光彩生門戶。
遂令天下父母心,不重生男重生女。
驪宮高處入青雲,仙樂風飄處處聞。
緩歌慢舞凝絲竹,盡日君王看不足。
漁陽鼙鼓動地來,驚破霓裳羽衣曲。
九重城闕煙塵生,千乘萬騎西南行。
翠華搖搖行復止,西出都門百餘里。
六軍不發無奈何,宛轉蛾眉馬前死。
花鈿委地無人收,翠翹金雀玉搔頭。
君王掩面救不得,回看血淚相和流。
黃埃散漫風蕭索,雲棧縈紆登劒閣。
峨嵋山下少人行,旌旗無光日色薄。
蜀江水碧蜀山青,聖主朝朝暮暮情。
行宮見月傷心色,夜雨聞鈴腸斷聲。
天旋日轉迴龍馭,到此躊躇不能去。
馬嵬坡下泥土中,不見玉顏空死處。
君臣相顧盡沾衣,東望都門信馬歸。
歸來池苑皆依舊,太液芙蓉未央柳。
芙蓉如面柳如眉,對此如何不淚垂。
春風桃李花開日,秋雨梧桐葉落時。
西宮南內多秋草,落葉滿階紅不掃。
梨園弟子白髮新,椒房阿監青娥老。
夕殿螢飛思悄然,孤燈挑盡未成眠。
遲遲鐘鼓初長夜,耿耿星河欲曙天。
鴛鴦瓦冷霜華重,翡翠衾寒誰與共。
悠悠生死別經年,魂魄不曾來入夢。
臨邛道士鴻都客,能以精誠致魂魄。
為感君王輾轉思,遂教方士殷勤覓。
排空馭氣奔如電,升天入地求之遍。
上窮碧落下黃泉,兩處茫茫皆不見。
忽聞海上有仙山,山在虛無縹緲間。
樓閣玲瓏五雲起,其中綽約多仙子。
中有一人字太真,雪膚花貌參差是。
金闕西廂叩玉扃,轉教小玉報雙成。
聞道漢家天子使,九華帳裏夢魂驚。
攬衣推枕起徘徊,珠箔銀屏迤邐開。
雲髻半偏新睡覺,花冠不整下堂來。
風吹仙袂飄颻舉,猶似霓裳羽衣舞。
玉容寂寞淚闌干,梨花一枝春帶雨。
含情凝睇謝君王,一別音容兩渺茫。
昭陽殿裏恩愛絕,蓬萊宮中日月長。
回頭下望人寰處,不見長安見塵霧。
唯將舊物表深情,鈿合金釵寄將去。
釵留一股合一扇,釵擘黃金合分鈿。
但教心似金鈿堅,天上人間會相見。
臨別殷勤重寄詞,詞中有誓兩心知。
七月七日長生殿,夜半無人私語時。
在天願作比翼鳥,在地願為連理枝。
天長地久有時盡,此恨綿綿無絕期。

 

詩仙『比擬』清平調︰

清平調‧李白

雲想衣裳花想容,春風拂檻露華濃。
若非羣玉山頭見,會向瑤臺月下逢。

一枝紅艷露凝香,雲雨巫山枉斷腸。
借問漢宮誰得似?可憐飛燕倚新妝!

名花傾國兩相歡,長得君王帶笑看。
觧釋春風無限恨,沈香亭北倚闌干。

全唐詩·卷164 天寶中,白供奉翰林。禁中初重木芍藥,得四本紅紫淺紅通白者,移植於興慶池東沈香亭。會花開,上乘照夜白,太真妃以步輦從。詔選梨園中弟子尤者,得樂一十六色。李龜年以歌擅一時,手捧檀板,押衆樂前,欲歌之。上曰:「賞名花,對妃子,焉用舊樂詞?」遂命龜年持金花牋,宣賜李白,立進《清平調》三章。白承詔,宿酲未解,因援筆賦之。龜年歌之,太真持頗梨七寶杯,酌西涼州蒲萄酒,笑領歌詞,意甚厚。上因調玉笛以倚曲,每曲徧將換,則遲其聲以媚之。太真飲罷,斂繡巾重拜。上自是顧李翰林尤異於他學士。

色入離 ☲ 目心火生,文字難寫飲水 ☵ 人。

生生不息如來藏?物理心理融一詞!

Color

Color (American English) or colour (Commonwealth English) is the characteristic of human visual perception described through color categories, with names such as red, yellow, purple, or blue. This perception of color derives from the stimulation of cone cells in the human eye by electromagnetic radiation in the spectrum of light. Color categories and physical specifications of color are associated with objects through the wavelength of the light that is reflected from them. This reflection is governed by the object’s physical properties such as light absorption, emission spectra, etc.

By defining a color space, colors can be identified numerically by coordinates. The RGB color space for instance is a color space corresponding to human trichromacy and to the three cone cell types that respond to three bands of light: long wavelengths, peaking near 564–580 nm (red); medium-wavelength, peaking near 534–545 nm (green); and short-wavelength light, near 420–440 nm (blue).[1][2] There may also be more than three color dimensions in other color spaces, such as in the CMYK color model, wherein one of the dimensions relates to a colour’s colorfulness).

The photo-receptivity of the “eyes” of other species also varies considerably from our own and so results in correspondingly different color perceptions that cannot readily be compared to one another. Honeybees and bumblebees for instance have trichromatic color vision sensitive to ultraviolet (an electromagnetic radiation with a wavelength from 10 nm (30 PHz) to 400 nm (750 THz), shorter than that of visible light but longer than X-rays) but is insensitive to red. Papilio butterflies possess six types of photoreceptors and may have pentachromatic vision.[3] The most complex color vision system in the animal kingdom has been found in stomatopods (such as the mantis shrimp) with up to 12 spectral receptor types thought to work as multiple dichromatic units.[4]

The science of color is sometimes called chromatics, colorimetry, or simply color science. It includes the perception of color by the human eye and brain, the origin of color in materials, color theory in art, and the physics of electromagnetic radiation in the visible range (that is, what is commonly referred to simply as light).

Colored pencils

Color effect – Sunlight shining through stained glass onto carpet (Nasir ol Molk Mosque located in Shiraz, Iran)

Colors can appear different depending on their surrounding colors and shapes. The two small squares have exactly the same color, but the right one looks slightly darker.

 

由於『顏色』『質感』深︰

Qualia

In philosophy and certain models of psychology, qualia (/ˈkwɑːliə/ or /ˈkwliə/; singular form: quale) are claimed to be individual instances of subjective, conscious experience. The term qualia derives from the Latin neuter plural form (qualia) of the Latin adjective quālis (Latin pronunciation: [ˈkʷaːlɪs]) meaning “of what sort” or “of what kind” in a specific instance like “what is it like to taste a specific orange, this particular orange now”. Examples of qualia include the pain of a headache, the taste of wine, and the perceived redness of an evening sky. As qualitative characters of sensation, qualia stand in contrast to “propositional attitudes“.[1] where the focus is on beliefs about experience rather than what is it directly like to be experiencing.

Philosopher and cognitive scientist Daniel Dennett once suggested that qualia was “an unfamiliar term for something that could not be more familiar to each of us: the ways things seem to us”.[2]

Much of the debate over their importance hinges on the definition of the term, and various philosophers emphasize or deny the existence of certain features of qualia. Consequently, the nature and existence of various definitions of qualia remain controversial in light of the fact that the existence of qualia has never been independently and scientifically proven as fact.

 

光譜數學難為功︰

Physics of color

Electromagnetic radiation is characterized by its wavelength (or frequency) and its intensity. When the wavelength is within the visible spectrum (the range of wavelengths humans can perceive, approximately from 390 nm to 700 nm), it is known as “visible light”.

Most light sources emit light at many different wavelengths; a source’s spectrum is a distribution giving its intensity at each wavelength. Although the spectrum of light arriving at the eye from a given direction determines the color sensation in that direction, there are many more possible spectral combinations than color sensations. In fact, one may formally define a color as a class of spectra that give rise to the same color sensation, although such classes would vary widely among different species, and to a lesser extent among individuals within the same species. In each such class the members are called metamers of the color in question.

Continuous optical spectrum rendered into the sRGB color space.

Spectral colors

The familiar colors of the rainbow in the spectrum – named using the Latin word for appearance or apparition by Isaac Newton in 1671 – include all those colors that can be produced by visible light of a single wavelength only, the pure spectral or monochromatic colors. The table at right shows approximate frequencies (in terahertz) and wavelengths (in nanometers) for various pure spectral colors. The wavelengths listed are as measured in air or vacuum (see refractive index).

The color table should not be interpreted as a definitive list – the pure spectral colors form a continuous spectrum, and how it is divided into distinct colors linguistically is a matter of culture and historical contingency (although people everywhere have been shown to perceive colors in the same way[6]). A common list identifies six main bands: red, orange, yellow, green, blue, and violet. Newton’s conception included a seventh color, indigo, between blue and violet. It is possible that what Newton referred to as blue is nearer to what today is known as cyan, and that indigo was simply the dark blue of the indigo dye that was being imported at the time.[7]

The intensity of a spectral color, relative to the context in which it is viewed, may alter its perception considerably; for example, a low-intensity orange-yellow is brown, and a low-intensity yellow-green is olive-green.

Color of objects

The color of an object depends on both the physics of the object in its environment and the characteristics of the perceiving eye and brain. Physically, objects can be said to have the color of the light leaving their surfaces, which normally depends on the spectrum of the incident illumination and the reflectance properties of the surface, as well as potentially on the angles of illumination and viewing. Some objects not only reflect light, but also transmit light or emit light themselves, which also contribute to the color. A viewer’s perception of the object’s color depends not only on the spectrum of the light leaving its surface, but also on a host of contextual cues, so that color differences between objects can be discerned mostly independent of the lighting spectrum, viewing angle, etc. This effect is known as color constancy.

 

The upper disk and the lower disk have exactly the same objective color, and are in identical gray surroundings; based on context differences, humans perceive the squares as having different reflectances, and may interpret the colors as different color categories; see checker shadow illusion.

Some generalizations of the physics can be drawn, neglecting perceptual effects for now:

  • Light arriving at an opaque surface is either reflectedspecularly” (that is, in the manner of a mirror), scattered (that is, reflected with diffuse scattering), or absorbed – or some combination of these.
  • Opaque objects that do not reflect specularly (which tend to have rough surfaces) have their color determined by which wavelengths of light they scatter strongly (with the light that is not scattered being absorbed). If objects scatter all wavelengths with roughly equal strength, they appear white. If they absorb all wavelengths, they appear black.[8]
  • Opaque objects that specularly reflect light of different wavelengths with different efficiencies look like mirrors tinted with colors determined by those differences. An object that reflects some fraction of impinging light and absorbs the rest may look black but also be faintly reflective; examples are black objects coated with layers of enamel or lacquer.
  • Objects that transmit light are either translucent (scattering the transmitted light) or transparent (not scattering the transmitted light). If they also absorb (or reflect) light of various wavelengths differentially, they appear tinted with a color determined by the nature of that absorption (or that reflectance).
  • Objects may emit light that they generate from having excited electrons, rather than merely reflecting or transmitting light. The electrons may be excited due to elevated temperature (incandescence), as a result of chemical reactions (chemoluminescence), after absorbing light of other frequencies (“fluorescence” or “phosphorescence“) or from electrical contacts as in light emitting diodes, or other light sources.

To summarize, the color of an object is a complex result of its surface properties, its transmission properties, and its emission properties, all of which contribute to the mix of wavelengths in the light leaving the surface of the object. The perceived color is then further conditioned by the nature of the ambient illumination, and by the color properties of other objects nearby, and via other characteristics of the perceiving eye and brain.

 

如何話說自家事?!假借『經驗』求『證印』☆

ColorPy – A Python package for handling physical descriptions of color and light spectra.

Introduction and Motivation

ColorPy is a Python package that can convert physical descriptions of light – spectra of light intensity vs. wavelength – into RGB colors that can be drawn on a computer screen.  It provides a nice set of attractive plots that you can make of such spectra, and some other color related functions as well.  All of the plots in this documentation were created with ColorPy.

ColorPy is free software.  (‘Free’ as in speech and beer.)  It is released under the GNU Lesser GPL license.  You are free to use ColorPy for any application that you like, including commercial applications.  If you modify ColorPy, you should release the source code for your modifications.  You have no obligation to release any source for your products that just use ColorPy, however.

Several years ago, I developed some C++ code to do these kinds of physical color calculations.  Recently, I decided to port the code to Python, and publish the library as open source under the GNU LGPL license.  I decided to make use of (and assume the existence of) NumPy and MatPlotLib for this.  These libraries make it easy to make some nice, attractive, and informative, plots of spectra.  Besides, Python is just more fun than C++.

So what can ColorPy do?  The short answer, is to scan this document, and examine the various plots of spectra and their colors.  You can use ColorPy to make the same kinds of plots, for whatever spectra you have and are interested in.  ColorPy also provides conversions between several important three-dimensional ‘color spaces’, specifically RGB, XYZ, Luv, and Lab.  (There can be many different RGB spaces, depending on the particular display used to view the results.  By default, ColorPy uses the sRGB space, but you can configure it to use other RGB spaces if you like.)

Download ColorPy

License

Copyright (C) 2008 Mark Kness
Author – Mark Kness – mkness@alumni.utexas.net

ColorPy is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ColorPy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with ColorPy. If not, see http://www.gnu.org/licenses/.

Prerequisites

To use ColorPy, you must have installed the following:  Python, NumPy, and MatPlotLib.   Typically, SciPy is installed along with NumPy and MatPlotLib.  ColorPy doesn’t use SciPy explicitly, although MatPlotLib may require SciPy.  (I am not sure.)  ColorPy is a ‘pure’ Python distribution, so you do not need any extra software to build it.  I have tested ColorPy both on Windows XP and Ubuntu Linux, and it should run on any system where you can install the prerequisites.  If, for some reason, you can only install NumPy but not MatPlotLib, you should still be able to do many of the calculations, but will not be able to make any of the nice plots.

Types and Units

ColorPy generally uses wavelengths measured in nanometers (nm), 10-9 m.  Otherwise, typical metric units are used.  For descriptions of spectra, ColorPy uses two-dimensional NumPy arrays, with two columns and an arbitrary number of rows.  Each row of these arrays represents the light intensity for one wavelength, with the value in the first column being the wavelength in nm, and the value in the second column being the light intensity at that wavelength.  ColorPy can provide a blank spectrum array, via colorpy.ciexyx.empty_spectrum(), which will have rows for each wavelength from 360 nm to 830 nm, at 1 nm increments.  (Wavelengths outside this range are generally ignored, as the eye cannot see them.)  However, you can create your own spectrum arrays with any set of wavelengths you like.

Color values are represented as three-component NumPy vectors.  (One-dimensional arrays).  Typically, these are vectors of floats, with the exception of displayable irgb colors, which are arrays of integers (in the range 0 – 255).

Fundamentals – Mapping spectra to three-dimensional color values

We are interested in working with physical descriptions of light spectra, that is, functions of intensity vs. wavelength.  However, color is perceived as a three-dimensional quantity, as there are three sets of color receptors in the eye, which respond approximately to red, green and blue light.  So how do we reduce a function of intensity vs. wavelength to a three-dimensional value?

This fundamental step is done by integrating the intensity function with a set of three matching functions.  The standard matching functions were defined by the Commission Internationale de l’Eclairage (CIE), based on experiments with viewers matching the color of single wavelength lights.  The matching functions generally used in computer graphics are those developed in 1931, which used a 2 degree field of view.  (There is also a set of matching functions developed in 1964, covering a field of view of 10 degrees, but the larger field of view does not correspond to typical conditions in viewing computer graphics.)  So the mapping is done as follows:

X = ∫ I (λ) * CIE-X (λ) * dλ
Y = ∫ I (λ) * CIE-Y (λ) * dλ
Z = ∫ I (λ) * CIE-Z (λ) * dλ

where I (λ) is the spectrum of light intensity vs. wavelength, and CIE-X (λ), CIE-Y (λ) and CIE-Z (λ) are the matching functions.  The CIE matching functions are defined over the interval of 360 nm to 830 nm, and are zero for all wavelengths outside this interval, so these are the bounds for the integrals.

So what do these matching functions look like?  Let’s take a look at a plot (made with ColorPy, of course.)


Figure 1 – The 1931 CIE XYZ matching functions.

This plot shows the three matching functions vs. wavelength.  The colors underneath the curve, at each wavelength, are the (approximate) colors that the human eye will perceive for a pure spectral line at that wavelength, of constant intensity.  The apparent brightness of the color at each wavelength indicates how strongly the eye perceives that wavelength – the intensity for each wavelength is the same.  (The next section will explain how we get the RGB values for the colors.)

 

 

 

 

 

 

 

 

 

GoPiGo 小汽車︰格點圖像算術《彩色世界》詩說

絕句‧杜甫

兩個黄鸝鳴翠柳,
一行白鷺上青天。
窗含西嶺千秋雪,
門泊東吳萬里船。

詩聖杜甫七言絕句有四首

堂西長筍别開門,塹北行椒卻背村。
梅熟許同朱老吃,松高擬對阮生論。

欲作魚梁雲複湍,因驚四月雨聲寒。
青溪先有蛟龍窟,竹石如山不敢安。

兩個黄鸝鳴翠柳,一行白鷺上青天。
窗含西嶺千秋雪,門泊東吳萬里船。

藥條藥甲潤青青,色過棕亭入草亭。
苗滿空山慚取譽,根居隙地怯成形。

 

,何必特舉其三說?難悟實相金剛義!娑婆世界有情多,純量造化色菩提☆★

彩色視覺

彩色視覺color vision)是一個生物體或機器基於物體所反射,發出或透過的波長(或頻率) 以區分物體的能力。顏色可以以不同的方式被測量和量化;事實上,人對顏色的感知是一個主觀的過程,即,腦響應當進入的光與中的若干種視錐細胞作用時所產生的刺激。在本質上,不同的人也許會以不同的方式看同一個物體。

無色綠色紅色濾鏡數位相機成像(「知覺」)。

波長和色調檢測

艾薩克·牛頓發現白光在通過一個三稜鏡時,會分解成它的組成顏色 ,但是如果這些彩色光帶通過另一個三稜鏡重新混合,它們會組成一個白色光束。特徵性的顏色從低到高頻率依次是:紅、橙、黃、綠、青、藍、紫。足夠的頻率差異引起感知到的色調的差異;波長的最小可覺差在藍綠和黃所在波長處的約1 nm到紅與藍處的10 nm或更多之間變動。儘管眼可以區分至多幾百種色調,當這些純的光譜色Spectral color)被混合在一起或者被白光稀釋時,可區分的色度可以相當高。

在非常低的光照水平下,視覺是暗視覺Scotopic vision)——光由視網膜上的視杆細胞檢測。視杆細胞於500 nm附近的波長最敏感,而且在彩色視覺中只起很少的作用。在更明亮的光下,比如白天,視覺則是亮視覺Photopic vision)——光由負責彩色視覺的視錐細胞檢測。視錐細胞對一個範圍內的波長敏感,但是於接近555 nm的波長最敏感。在這兩個區域之間,中間視覺Mesopic vision)則起作用,視錐和視杆細胞均提供信號給視網膜神經節細胞Retinal ganglion cell)。從暗光到亮光,色彩感知的改變引起了叫做薄暮現象的差異。

對「白色」的感知由整個可見光的光譜形成,或者通過混合少數幾種波長的顏色,例如紅、綠和藍,或者通過混合僅僅一對互補色例如藍和黃。[1]

顏色感知的現代模型。它發生於視網膜中,與19世紀引入的三色視覺Trichromacy)和opponent processOpponent process)理論均有關。

 

人視覺系統的相對光亮敏感度,作為波長的函數。

顏色感知的生理機制

對顏色的感知開始於特化的含有具不同光譜敏感度Spectral sensitivity)的色素的視網膜細胞,稱為視錐細胞。在人類中,有3種對3種不同的光譜敏感的視錐細胞,造成了三色視覺Trichromacy)。

每個單獨的視錐細胞包含由載脂蛋白視蛋白Opsin)組成的色素,該色素共價連接於11-順-氫化視黃醛或者更罕見的11-順-脫氫視黃醛之一上。[2]

視錐細胞傳統上按照它們的光譜敏感度Spectral sensitivity)峰值波長的順序被標記為:短(S)、中(M)、和長 (L)的視錐細胞類型。這三種類型不完全對應於如我們所知的特定的顏色。相反,對顏色的感知是由一個開始於這些位於視網膜的細胞差異化的輸出 ,且將在大腦的視覺皮層和其它相關區域中完成的複雜的過程實現的。

例如,儘管L視錐細胞簡稱為紅色感受器,紫外-可見分光光度法表明它們的峰值敏感度在光譜的綠黃色區域。類似的,S- 和M-視錐細胞也不直接對應藍色綠色,儘管它們經常被這樣描述。重要的是注意RGB色彩模型僅僅是用以表達顏色的一個方便的方式,而不是直接基於人眼中的視錐細胞類型。

人視錐細胞的峰值響應因人而異,即使在具有「正常」彩色視覺的個體之間也是如此;[3]在一些非人的物種之中這種多態的差異甚至更大,而它很可能有適應性的優勢。[4]

人的S、M和L類別視錐細胞對單色光譜刺激的歸一化的響應光譜,波長以奈米為單位。

 

與上圖一樣的圖形,此處用具三個(歸一化的視錐細胞響應)維度的單一曲線表示。

彩色視覺的理論

關於彩色視覺的兩種互補的理論分別是三色視覺Trichromacy)理論和互補處理Opponent process)理論。三色視覺理論,或者楊-亥姆霍茲理論Young–Helmholtz theory),19世紀時由托馬斯·楊赫爾曼·馮·亥姆霍茲提出,如上述所說,說明了視網膜的三種視錐細胞分別優先敏感於藍、綠和紅色。Ewald HeringEwald Hering)則於1872年提出互補處理理論。[5]它則表明視覺系統以一種拮抗的方式解釋顏色:紅對綠,藍對黃,黑對白。現在知道,這兩個理論都是正確的,描述視覺生理的不同階段,如右圖所示。[6]綠←→品紅和藍←→黃是具有相互排斥的邊界的標度。就像不可能存在「有一點點負」的正數一樣,以相同的方式一個人不可能感知到有點藍的黃或者有點紅的綠。

人眼中的視錐細胞

視錐類型 名稱 範圍 峰值波長[7][8]
S β 400–500 nm 420–440 nm
M γ 450–630 nm 534–555 nm
L ρ 500–700 nm 564–580 nm

一系列波長的光以不同程度刺激這些感受器中的每一種。例如,黃綠色的光以一樣的強度刺激L和M視錐細胞,但僅僅微弱的刺激S視錐細胞。紅色光,在另 一方面,刺激L視錐細胞遠多於M視錐細胞,而幾乎不刺激S視錐細胞;藍綠色光刺激M視錐細胞多於其刺激L視錐細胞,刺激S視錐細胞也更強烈,也是視杆細胞 的峰值刺激;藍色光比紅色或綠色的光更加強烈的刺激S視錐細胞,但更弱的刺激L或M視錐細胞。大腦組合來自每種受體的信息以產生對不同波長的光的不同感知。

於L和M視錐細胞中存在的視蛋白(光敏色素)編碼於X染色體上;對這些蛋白質有缺陷的編碼導致最常見的兩種形式的色盲OPN1LWOPN1LW)基因,編碼L視錐細胞中的視蛋白,是高度多態的(Verrelli和Tishkoff最近所做的一個研究在一個236個男人的樣本中發現了85種變體)。[9]極少數的女人可能有一種額外的顏色受體,因為她們在每個X染色體上有編碼L視蛋白的不同等位基因。X染色體去活化意味著在每一個視錐細胞中只有一種視蛋白被表達,而一些女人可能因此展現出一定程度的四色視覺Tetrachromacy)。[10]OPN1MWOPN1MW) – 編碼於M視錐細胞中表達的視蛋白 – 的變體,看起來很罕見,觀測到的變體也對光譜敏感度無影響。

 

不空強空成頑空,空空不空有時盡,一念大悲觀自在,人間哪處非紅塵!!??