The color of the moon and the sun from space in the values of RGB and color temperature

My purely personal opinion is nothing but a consequence of the interference of politics in science. After all, the colors of the Moon and the Sun from space directly relate to the flights of Americans to the Moon.
I searched through many scientific articles and books in search of information about the color of the moon and the sun from space. Fortunately, it turned out that even though they do not have a direct answer in RGB, there is complete information about the spectral density of the solar radiation and the reflectivity of the moon in the spectrum. This is enough to get the exact colors in the RGB values. You just need to carefully calculate what, in fact, I did. In this article I will share the results of the calculations with you and, of course, I will tell you in detail about the calculations themselves. And you will see the moon and the sun from space in real colors!
I performed the calculations in the Mathcad program and, accordingly, the code fragments will be in the built-in programming language, which is quite suitable as a pseudo-code that is understandable to all.
At the same time, I’ll tell you in detail what is the RGB color model, with which, I think, you are all familiar. This question is actually not entirely simple either. For example, try to answer the following two questions. Let the color
1) What are the values of RGB color, which is 2 times darker than the specified?
2) What are the RGB values for gray that have the same brightness as the given?
It would seem that what is there to think, divide by 2 in the first case, i.e. rgb (60,40,50) and average in the second case, i.e.
I will also talk about color temperature and how to calculate it.
XYZ color space
XYZ is a reference color model defined in the strict mathematical sense by CIE (International Commission on Illumination) in 1931. Model CIE XYZ is a master model of almost all other color models used in technical fields. XYZ color is set as follows:
Where
The color matching function data I downloaded from here:

The graphs show that above
I calculate the indicated integrals by the trapezoid method :

where c is the coordinate number of the color space (1, 2, 3 for X, Y, Z, respectively); cw - table of color matching functions; f is the spectral density;
The correct color matching functions have the property that the area under all three curves is the same:
This is done so that the uniform spectrum has the same XYZ coordinates. Check if this property holds:

where one is an array of 1; cmf2_ and cmf10_ are color matching function tables for the

Brightness normalization
Consider the operation of a digital camera. The main element of a digital camera is a matrix, which consists of photosensors. When projecting an image onto a matrix, an electric charge is proportional to each of its photosensors, which is proportional to the radiation energy of the photosensor. Photosensors capture the brightness of an image element without any information about its color. To obtain information about color, the matrix of photosensors is covered with a matrix of miniature light filters on top. These filters serve as color matching functions. Each pixel consists of several photosensors, which in total are superimposed all kinds of filters.
So, as a function
where illumination is the spectral radiation density of the light source; albedo - reflectivity of the surface of the photographed object; coef - a certain constant coefficient, which is determined by the exposure time, aperture, distance from the light source to the photographed object and other factors. Reflectance refers to the apparent albedo , which is defined as the ratio of the brightness of a flat surface element illuminated by a parallel beam of rays to the brightness of a completely white surface perpendicular to the rays.
Now imagine that we are doing the work of a photo exposure meter, with which the photographer sets the shutter speed and aperture on the camera. In other words, we need to choose the coef value so that the picture turns out to be normal in brightness, not too dark, not too bright. Imagine that behind the photographed object is a completely white screen. The reflectance albedo of such a screen is by definition equal to 1 at all wavelengths. Set the coef value so that the visual brightness Y of this screen in the image is 1. Why 1? Because in the RGB color model, the maximum possible brightness value is 1, which is achieved with
It should be noted that such a normalization does not guarantee that the value of each RGB coordinate will be less than or equal to 255. For example, if you shoot an absolutely white screen with a red light source, then the RGB color will skyrocket.
So, I calculate the coordinates of the XYZ color space as follows:

We need to somehow express the color of the sun. We cannot photograph it directly, and in our mathematical model we did not provide such an extreme case. Obviously, we need to photograph the white surface illuminated by the Sun. Since the Sun from outer space has a reddish hue, then, as I said, the color of an absolutely white screen goes off scale. Therefore, we must take the surface darker. I experimentally found that you need to take white paper with an albedo of 0.91. You can’t take more albedo, it begins to roll over. Thus, in order to get the color of the Sun, I just set the albedo value to 0.91 at all wavelengths in the above formula :

SRGB color space
The most common color space using the RGB model is sRGB. Therefore, when talking about RGB without clarification, they mean the sRGB color space, which is the standard for representing the color spectrum using the RGB model. This standard was created by the International Color Consortium (ICC) in 1996 to unify the use of the RGB model in monitors, printers, and Internet sites. Let's look at this standard, a description of which is available at
The conversion of XYZ to sRGB takes place in three stages. First, the XYZ coordinates are converted to linear RGB coordinates, then the linear coordinates are converted to non-linear RGB coordinates, and finally the non-linear coordinates are converted to 8-bit RGB coordinates, which, in fact, are the coordinates of the sRGB color space.
The conversion of XYZ coordinates to linear RGB coordinates is as follows: the

opposite is true:

I wonder where did these strange numbers come from in square matrices? And they came from the recommendation ITU-R BT.709
We introduce the following functions:
Then the requirements of recommendation ITU-R BT.709 take the following form:
We have 8 equations, when we have 9 unknown elements of the RGB_to_XYZ matrix , that is, one more equation is missing. And the missing equation was implicitly set, I had to guess it myself. The essence of this equation is that for white, the visual brightness Y should be equal to 1:
I found the exact solution to these equations in rational numbers:

If I round the numbers in my result to four decimal places, we get exactly the same strange numbers in the standard of the International Color Consortium. In my calculations, I use not rounded matrices, but the above exact ones (as far as double-precision floating-point numbers allow ).
So, the linear coordinates of RGB based on the table of color matching functions (cmf), spectral radiation density (illumination) and reflectance (albedo) I calculate as follows:

I also use linear RGB coordinates averaged over

From the linear coordinates of RGB, the visual brightness Y is calculated using the following formula (by default, Mathcad arrays are numbered from the zero element): We

continue to parse the standard. Each linear RGB coordinate is converted to non-linear using the non-linear lin2bit function, and vice versa, bit2lin, which are defined as follows: The

graphs of these functions look like this:

Note that 0 is converted to 0, 1 to 1.
At the end, non-linear RGB coordinates are converted to 8- bit multiplication by 255 followed by rounding to integers.
Thus, I have defined the following functions for converting linear RGB coordinates to 8-bit and vice versa:

Now we are ready to solve the problem from the introduction. I remind you of the condition.
Let
1) What are the values of RGB color, which is 2 times darker than the specified?
2) What are the RGB values for gray that have the same brightness as the given?
Solution:

Answers: 1)
Colour temperature
The color temperature of the light source, measured in Kelvin, is determined by the temperature of a completely black body located on the color chart in the same place as the radiation source in question. If the light source does not fall on the Planck curve (a curve that is determined by the set of color points of a black body at different temperatures), a correlated color temperature is used to characterize it. This value is also measured in Kelvin and is determined by the temperature of a completely black body, the color of which is as close as possible to the color of the light source. To find the correlated color temperature of the radiation source in the color chart plotted in the coordinates
For a completely black body of temperature T, the radiation power per unit area of the radiating surface in a unit wavelength interval is expressed by Planck's law :
Accordingly, I calculate the spectral radiation density of an absolutely black body as follows (the wavelengths in nanometers are in the zero column of the color matching function cmf2 table):

Please note that I omitted the constant factor, because it still decreases with further normalization by brightness (the brightness of the light source does not affect the color temperature).
Next, I calculate the linear coordinates of RGB: The

linear coordinates of RGB are converted into coordinates

On the plane

For example, for a standard white light source, the dependence of this distance on temperature looks like this:

The value of T, at which this dependence has a minimum, is the color temperature of the light source in question.
The spectral density of the radiation of the sun
I downloaded the data of the spectral density of solar radiation in the absence of the atmosphere from here:
As will be shown below, the D65 and E490 light sources have color temperatures of 6467K and 5912K, respectively. The spectral radiation densities of light sources D65, E490 and absolutely black bodies of the corresponding temperatures are as follows:

It can be noted that the spectral radiation density of the Sun is higher than that of a white light source at longer wavelengths, i.e., at wavelengths of red light (620- 770 nm). This means that the sun has a reddish tint. Indeed, the calculations give the following colors of the light sources D65, E490 and absolutely black bodies of the corresponding temperatures (as I said, white paper with an albedo of 0.91 is considered):

Note that the sRGB coordinates of the Sun and the absolutely black body of temperature 5912K exactly match. This is not explained by anything, it just happens.
The color of the circles in the last picture is the real color of the Sun from space. The human eye clearly sees the reddish tint of the sun. So, the fact that the Sun from space is white is a big myth! It should be noted that for some reason this shade is not observed in the photographs and video of the Apollo program. In these photographs, the visible reddish hue of the Sun would certainly appear on the white surfaces of the American flag and spacesuits. And as will be shown below, this shade of the Sun makes a noticeable contribution to the "redness" of the Moon from space.
Is the moon different or the same in color?
Opponents of the theory of the lunar conspiracy are promoting the version that the moon is different in color. Allegedly in places the moon is gray, in places it is brown, and at the same time the Apollo landed where the moon is gray. But this version directly contradicts scientific data. The article
Color differences on the moon are extremely small.
Shevchenko also writes in his book
For many years, the famous American researcher T. McCord worked in this direction. He obtained more than 200 spectra for various sections of the lunar surface measuring 10–20 km each. All obtained curves are basically similar in appearance.
So, no, the moon is not different in color, but the same.
Color data of the moon according to Shevchenko
Shevchenko in his book

In my calculations, I use piecewise linear interpolation of this data. I received the missing data in the range of 820–830 nm by direct continuation of the segment in the range of 690–820 nm.
Moon Color Data by LRO
The dependence of the lunar surface reflectivity on the conditions of illumination and observation at wavelengths from 321 nm to 689 nm is given in

The phase angle can be expressed in terms of the azimuthal angle
In the calculations, I take the traditional values of the angles

I made a linear extrapolation of the LRO data to the interval 689-830 nm so that the ratio of the values at the points 830 nm and 689 nm was the same as the Shevchenko data ( schedule shev). I also renormalized Shevchenko’s data by multiplying by 0.8315 so that the brightness of the resulting color calculations according to Shevchenko and LRO were the same.
Color Information for the Moon by Kaguya
The work
But the work is interesting in that it talks about the colossal discrepancies of the Kaguya data with the data of the Apollo 16 mission. And this is one of the rare cases when the scientific community openly speaks of inconsistencies associated with the flights of Americans to the moon.
Calculation results
Further I will use the following notation:
D65 - a standard source of white light D65;
E490 - light source from the Sun in the absence of atmosphere;
D65
B-0.91 LRO (30 °) Shevch. ling. (2 °) 0.9076,0.9120,0.8968 0.1177,0.0931,0.0688 0.1202,0.0931,0.0697 ling. (10 °) 0.9084,0.9122,0.8929 0.1165.0.0916.0.0687 0.1188,0.0917,0.0696 ling. (average) 0.9080,0.9121,0.8948 0.1171,0.0924,0.0688 0.1195,0.0924,0.0697 sRGB (100%) rgb (244,245,243) rgb (96.86.74) rgb (97.86.75) sRGB (200%) - rgb (133,119,104) rgb (134,119,104) sRGB (300%) - rgb (160,144,125) rgb (161,144,126) sRGB (400%) - rgb (182,164,143) rgb (184,164,144) col. pace. 6467K 4928K 4891K
E490
B-0.91 LRO (30 °) Shevch. ling. (2 °) 1.0005,0.8892,0.8490 0.1283.0.0909.0.0649 0.1310,0.0909,0.0657 ling. (10 °) 1.0021,0.8888,0.8483 0.1272.0.0895.0.0650 0.1297.0.0895.0.0659 ling. (average) 1.0013,0.8890,0.8486 0.1277,0.0902,0.0649 0.1303.0.0902.0.0658 sRGB (100%) rgb (255,242,237) rgb (100.85.72) rgb (101.85.73) sRGB (200%) - rgb (138,118,101) rgb (140,118,102) sRGB (300%) - rgb (166,142,122) rgb (168,142,123) sRGB (400%) - rgb (189,162,139) rgb (191,162,140) col. pace. 5912K 4550K 4512K
The following image shows the lunar surface colors

As you can see, the Moon from outer space has a brown color both according to the LRO data and according to Shevchenko. By Shevchenko it turns out a little (barely noticeable) redder than by LRO.
Color of the moon in photos
In this section we will deal with the coloring of photographs. Let the image img and color in linear coordinates of RGB be given . Each image pixel is replaced by a pixel of a given color of the same brightness as that of the color of the original pixel. The image in Mathcad is presented as a single sRGB coordinate matrix, which is obtained by stitching the three matrices “R”, “G”, “B” from left to right. With this in mind, the coloring procedure is as follows:

For fun, I took photographs of the lunar surface from the Apollon US photo albums and repainted them in the colors obtained from my calculations. I give only the results, and make a conclusion about whether these photos are genuine or false, yourself.
Result of coloring of a photograph AS11-44-6552:

In the middle are the original photos. On the left, the photographs are colored according to the LRO data for traditional angles
As you can see, the reddish hue of the Sun makes a noticeable contribution to the “redness" of the surface of the Moon, which in the end looks brown, not gray at all.
The gray color of the moon in NASA photographs could be explained by the fact that the film for some reason “went” blue, but this version immediately disappears if we analyze the images of gray gradations at the end of the albums. The photo as11-44-chart shows such a picture for the last photo above. I left real grays of the same brightness on the left of the gradations of gray in the same brightness as in the photograph, and also wrote down the sRGB coordinates. As a result, the following image was obtained:

As you can see, the film not only didn’t “go” to blue, but even “left” a little in the opposite direction from blue. Such a deviation cannot turn brown into gray.
The result of coloring the photo AS11-40-5903 :

In the original photograph, the lunar surface in places has not just a gray color, but even a slight bluish tint. The as11-40-chart photo shows the corresponding image of gray gradations:

The film "went" not to "blue" color, but to "red". And even after that, for some reason, the lunar surface in NASA's photograph is gray.
Result of coloring a photograph AS11-37-5455 :

This is one of the rare photographs of the Apollo program, where the lunar surface has a brown tint, albeit not entirely. Opponents of the theory of the lunar conspiracy love to show it, they say, look, brown is the same. But here the catch crept in. Let's analyze the photo as11-37-chart , which shows the corresponding image of gray gradations:

The film simply “went” brown. That's the whole reason for the brown tint of the lunar surface in NASA photographs.
The dependence of the color of the lunar surface on lighting conditions and observation
Using the LRO data given in

As you can see from the picture, only the brightness changes. In the bottom row, the colors are almost the same everywhere for the human eye. Although, if you look closely, in the case
The color of the lunar soil
There is a very strange photograph on NASA's website, namely this photograph of the lunar soil sample No. 10005 .

The lunar soil in the photograph looks brown, even too brown, given that the lighting was produced by a white light source. The correct white balance can be checked by the color of the white paper that fell into the frame.
Maybe this is the same orange soil that the Apollo 17 astronauts discovered? Not! The document
Now let’s listen to what Neil Armstrong (Apollo 11 astronaut) says in an interview with Patrick Moore
When you look at the ground near or in your hand, you find that it is actually coal gray, and we especially could not find anything different from this color.
(When you look at the material at close range, as if in your hand, you find it's a charcoal gray in fact, and we were never able to find any things that were very different from that color.)
It turns out, Neil Armstrong, I’m not afraid of the word, lied.
Literature
1. Color & Vision Research Laboratory - New CIE XYZ functions transformed from the CIE (2006) LMS functions
2.International Color Consortium - A Standard Default Color Space for the Internet: sRGB
3.Recommendation ITU-RBT.709 - Parameter values for the HDTV standards for production and international program exchange
4.Robertson R. “Computation of correlated color temperature and distribution temperature” /.Opt. Soc. Am. 58, 1528 (1968).
5.2000 ASTM Standard Extraterrestrial Spectrum Reference E-490-00
6.CIE Standard Illuminant D65
7.“The First Results of Determining the Physico-Mechanical Properties of the Soils of the Moon”, Moscow: 1970. Gosstroy, USSR, under the editorship of prof. Dr. tech. Sciences of V. G. Bulychev, p. 8.
8.Shevchenko V.V., Moon and its observation, 1983, pp. 91-92.
9.Hapke, B., B. Denevi, H. Sato, S. Braden, and M. Robinson (2012), The wavelength dependence of the lunar phase curve as seen by the Lunar Reconnaissance Orbiter Wide-Angle Camera, J. Geophys. Res., 117, E00H15
10.Ohtake, M. et al. (2010), Deriving the Absolute Reflectance of Lunar Surface Using SELENE (Kaguya) Multiband Imager Data, Space Sci. Rev. 154, 57-77
11.THE APOLLO 11 DRIVE TUBES, Dissection and description by Judith H. Allton, NASA (1978)
12.BBC Neil Armstrong Interview with Patrick Moore (1970)