[Physics] Why does the sky suddenly look gray through this window

everyday-lifeperceptionsunvisible-lightvision

I am looking to the windowed roof of my building, and I notice that the sky, which has few white clouds, sometimes looks completely gray, as if there was a huge cover of gray clouds, but there are not.

By observing it and waiting for the change to happen, I notice it takes a matter of seconds : when the sun shines directly on the building (but not directly on me), the blue sky turns gray. I wonder if this is just an optical illusion because my vision of colour could be relative to its environment, or if there is serious glass/sun/refraction effect or something. I haven't found anything on that matter on the internet or on Stack Exchange, so I'm asking you what you think about it.

Additional information : The top window is a very peculiar glass, it's basically a strong glass window (because it's almost horizontal, it has to resist hits) and looks like it is covered by a layer of opaque black, with big holes (surface of holes is greater than surface of black, from a distance you don't see the holes). Also, I'm taking the pictures from a windowed office, you see the sky through two glass windows, but the one closest to me looks basic and I didn't notice a difference when looking through one layer. You will also notice there is a blue light, some neon-like directed at the roof, but during the day its effect is negligible.

Here are the pictures, first the sky through top window without sun hitting the window, then with the sun (The colours/ exposition differences don't seem to make a great difference compared to my naked eye observation. The pictures were taken only a few seconds apart, you can see the same cloud in both pictures. The gray sky isn't the most grayish I've observed, it gets even farther away from blue sometimes) :

Sky through top window without sun hitting the window

Sky through top window with sun hitting the window

Best Answer

Let's try to validate and quantify the conjecture first raised by Carl Witthoft in a comment to the question, which is basically that the sky only appears less blue in the second picture because a lot more light is scattering off of the windows towards your camera.

If this is true, we ought to be able to see it. The first thing to do is convert the pictures from the relatively useless RGB colorspace to the much more useful XYZ colorspace which is built on a model of the actual receptors in the human eye. The $Y$ coordinate corresponds to the perceived luminance of the image (i.e. the average human response across the visible spectrum) and the $Z$ coordinate corresponds to our blue receptor response. The $X$ coordinate is set to be pick up the slack and doesn't necessarily have a clear physical interpretation. See here the responses across the visible spectrum: (from wikipedia):

XYZ color coordinates in terms of spectral response

So, that is the first thing I did. I obtained:

Decomposition of two images

Above you will see the two original pictures, as well as their $Y$ and $Z$ values. Here we can clearly see that the total illumination ($Y$) in the Gray picture has gone up, and the blue content of the image ($Z$) has gone up as well.

Let's try to take a closer look. To do that I will next look at a histogram of the $Y$ and $Z$ values in the images:

Histogram of $X$ and $Y$ response

Looking at this histogram of values, we can clearly see that at the middle levels (near ~ 0.5) both of the images have a blue hump. Let's assume that is the sky (we'll check in a second). But notice also that if anything that blue hump has shifted up a bit in activation. Sorta nearby the blue hump is a hump in the luminance ($Y$), which appears to move a lot. But there is a lot going on in the image, and if the conjecture is right and there is more light coming in through the windows, we would expect everything in the picture to be brighter, including the columns and wall. So, we need to try to filter the sky, so let's make a cut on the image given by those humps in the blue. I've shown my choices for the cuts as the vertical dashed lines in the image. Applying that cut to the original image we obtain:

Attempting to find just the sky

Absolutely wonderful! We've just developed a nearly perfect sky filter. Now that we know which pixels correspond to the sky, we can look again at our histograms, but this time only for "sky" pixels.

Histograms of $X$ and $Y$ for sky pixels

And now it would appear as though there is no denying Carl Witthoft's explanation, the sky appears less blue, in the "Gray Sky" picture, not because any of the blue has gone away (in fact if anything there is more blue content in it) but because there is just so much more light coming from those points beyond just the blue, and so it doesn't look blue anymore. For completeness, let's look at the histograms in the RGB channels of just the sky pixels:

RGB Histograms of Sky

Here we can clearly see that it is not that the blue went away, we just have a heck of a lot more red and green coming from the windows now.

But why does it look so much less blue, when the values of the red and green channels are still smaller than the blue?

That is entirely an effect of human perception. We are a lot less sensitive to blue light than we are to green. If you take a look at the plot at the top of this answer again, remember that the $Y$ curve was chosen to be the perceptual sensitivity of human subjects across the visible spectrum. Notice how little it overlaps with blue.

In fact, a common formula people use to convert images to grey scale (that is worse than the XYZ transformation, but easy to do) is:

$$ L = 0.21 R + 0.72 G + 0.07 B $$

This demonstrates the issue with just three numbers. Roughly 72% of what we perceive as brightness comes from the green channel, 21% comes from the red, and only 7% comes from the blue. This is why, when the sun shines on those windows in your building, even though there is more blue light coming in, and the blue components still dominate the other colors, it suddenly looks very drab indeed.

All of the code used to make these figures is available as an ipython notebook here.