# A few scanning tips

## A little more detail about Histograms

Maybe we shouldn't dwell on this, because it's not necessary nor greatly useful to know it to operate the scanner. But it might make the Histogram more comfortable to know a few more details, and to see a simplified example.

We want to measure the range of brightness of tones in our image, to help in setting shadow and highlight points. But absolute brightness is not very meaningful, because human eyes don't detect brightness linearly with color. Basically, we see Green as brighter than Blue. So, the term Luminance was invented, which is brightness adjusted to indicate appropriately what we really see.

Luminance is Gray tone brightness values computed from RGB via the formula:

RGB Luminance value   =   0.3 R + 0.59 G + 0.11 B

This is the grayscale luminosity from converting RGB colors, from the NTSC (National Television System Committee) 2nd specification in 1953 for color television. It is the brightness that colors appear on a grayscale screen.

There are other variations of this formula used, with slightly different numbers, but this one is fine to make our point here. When you convert a color image to grayscale in your photo editor, the default Grayscale menu will use a method like this. Photo editors do typically give us other methods to drastically modify the result we find pleasing, but the accurate conversion will be like this formula.

For example, a RGB color of (100, 150, 200) would compute its luminance as

(100 x 0.3) + (150 x 0.59) + (200 x 0.11) = 140

But if the color were (100, 200, 150), the luminance would be

(100 x 0.3) + (200 x 0.59) + (150 x 0.11) = 164

Meaning, the color with more Green is brighter to the eye than the color with more Blue. The purpose of luminance is to show that difference.

The luminance signal in your TV set uses the same formula, in fact, that was its origin.   Every RGB pixel computes to a 8 bit Luminance value between 0 and 255 (because 0.3 + 0.59 + 0.11 = 1.0).

This weighting is required because we see Green well, much better than we see Blue. Saturated Blue is dark to the human eye, and it doesn't contribute much to perceived brightness. Said another way, the sensitivity of the human eye peaks in the green-yellow colors. To make that point, here is a test image with all saturated colors (value 255). The Green is brighter than Blue or Red, even when mixed with Red or Blue. Actually, especially if it is mixed, because the Luminance value is proportional to the total of all of the RGB components, the weighted sum of all the components.

RGB color

As seen on a grayscale screen

Converting to Grayscale makes the point that the colors don't have equal apparent intensities. These three primary colors all have the same intensity value of 255, but the perceived brightness is different. Blue has less brightness and Green has more. Green plus Blue (Cyan) has even more. And Green plus Blue plus Red (White) has even more luminance, it is brighter.

Note:   In the RGB system, equal portions of

Blue and Green added make Cyan.
Red and Green added make Yellow.
Blue and Red added make Magenta (not shown here)
Blue and Red and Green added make White.

And here is a histogram of that sample image. It's exactly the same histogram for either image, because a histogram is a map of the grayscale Luminance values.   I have added the gray gradient scale across the bottom to better illustrate the purpose, and the range of tones that the histogram is showing. The numbers run from 0 at the left (Black) to 255 on the right (White), which show the all of the shades of gray between Black and White. (BTW, you'll have to convert images to at least 256 color mode to be able to get a histogram).

Horizontally, the histogram horizontal scale is a bar chart count of the 256 possible colors, [0..255]. We suppose there are only seven colors in this image, so we expect seven luminance values (a real color photograph would have tens or hundreds of thousands of colors, depending on which colors were actually present). Drifting off subject, but technically there are actually are a few more colors causing the little bit of extra width of the vertical lines, which is because most RGB color images add intermediate mixed colors at color boundaries (called aliasing) to smooth the edge that can causes appearance of jaggies (stair-step edges on a diagonal straight line). And in JPG files, the added JPG artifacts cause extra color confusions.

The histogram shows a bar chart of the count of pixels with each shade of color. Normally, we do not care about the absolute count. We care about the trend, or the balance of all tones compared together. This very limited sample of 7 tones hides that, but it will become clear in the next step.

The blue area in our image is recognizable as the largest graphic area of the same color value, therefore has the most pixels, therefore it has the largest (tallest) spike. The height is the count of pixels in the image that have that one luminance value.

Blue should also have the lowest luminance (closest to the left or zero or black end). Blue's Luminance of 28 doesn't show much different than Black's 0 in the Gray tones, but it really is 28. Adjusting your monitors brightness and contrast can affect how it looks at your house, your monitor uses luminance too.

The "Max 2250" is the tallest peak, the blue in our case, which the chart below confirms has a pixel area of 2250 pixels. The histogram graphs a bar chart of the count of the pixels with each possible tone.

My presentation unfortunately almost makes it look like the histogram is showing color. But it's not, it's showing Luminance of the colors. For example, if our Green sample were not saturated, if it had a RGB value of (0,100,0) instead of (0,255,0), then its luminance would be 0.59 x 100 = 59, which would be well less than our saturated Red sample. The histogram is showing the degrees of perceived brightness and darkness in our image.

For another example, the color Gray has the interesting property of having equal RGB values, with no color tint. So (50,50,50) is a dark Gray, and (200,200,200) is a light Gray. And Gray also has the characteristic that (50,50,50) has a Luminance of 50, and (200,200,200) has a Luminance of 200.

Here's a chart, made easy because of the solid saturated colors in our test sample. It has been sorted in order of increasing luminance. You can see the calculated values agree exactly with the histogram scale.

 Color Area Sizein pixels Areain pixels RGB Color Luminance from Red from Green from Blue Total K 53x30 1590 0, 0, 0 0 0 0 0 B 75x30 2250 0, 0, 255 0 0 255 x 0.11 28 R 66x30 1980 255, 0, 0 255 x 0.3 0 0 76 G 59x30 1770 0, 255, 0 0 255 x 0.59 0 150 Cyan 39x30 1170 0, 255, 255 0 255 x 0.59 255 x 0.11 178 Y 40x30 1200 255, 255, 0 255 x 0.3 255 x 0.59 0 227 W 52x30 1560 255, 255, 255 255 x 0.3 255 x 0.59 255 x 0.11 255

A real photo has a complicated histogram, so before we rush out into the real world, let's take a halfway step.

The small red image above is a small JPG file and its corresponding histogram. Actually, the histogram is from its TIF file, because the JPG image introduces artifacts that confuse the discussion of it. It is a graphic gradient ranging from Red (luminance about 80) to White (luminance 255). Again, the histogram just graphs a bar chart of the count of the pixels with each possible luminance tone. And in our real photos, it's not the count that's important, but instead the shape of the curve, how the masses of light and dark pixels contribute to the total. Obviously this bright test image has tones fairly evenly distributed in the upper 2/3 of the range, and is quite barren in the low 1/3.