Image processing basic(1)
GRAYSCALE IMAGE
In photography and computing, a grayscale or greyscale digital image is an image in which the value of each pixel is a single sample, that is, it carries only intensity information. Images of this sort, also known as black-and-white, are composed exclusively of shades of gray, varying from black at the weakest intensity to white at the strongest.
Grayscale images are distinct from one-bit black-and-white images, which in the context of computer imaging are images with only the two colors, black, and white (also called bilevel or binary images). Grayscale images have many shades of gray in between. Grayscale images are also called monochromatic, denoting the absence of any chromatic variation.
Grayscale images are often the result of measuring the intensity of light at each pixel in a single band of the electromagnetic spectrum (e.g. infrared, visible light, ultraviolet, etc.), and in such cases they are monochromatic proper when only a given frequency is captured. But also they can be synthesized from a full color image; see the section about converting to grayscale.
To convert any color to a grayscale representation of its luminance, first one must obtain the values of its red, green, and blue (RGB) primaries in linear intensity encoding, by gamma expansion. Then, add together 30% of the red value, 59% of the green value, and 11% of the blue value (these weights depend on the exact choice of the RGB primaries, but are typical). Regardless of the scale employed (0.0 to 1.0, 0 to 255, 0% to 100%, etc.), the resultant number is the desired linear luminance value; it typically needs to be gamma compressed to get back to a conventional grayscale representation.
GAMMA ENCODING
Gamma correction, gamma nonlinearity, gamma encoding, or often simply gamma, is the name of a nonlinear operation used to code and decode luminance or tristimulus values in video or still image systems. Gamma correction is, in the simplest cases, defined by the following power-law expression:
V(out)=V(in)^gamma
where the input and output values are non-negative real values, typically in a predetermined range such as 0 to 1. A gamma value
is sometimes called an encoding gamma, and the process of encoding with this compressive power-law nonlinearity is called gamma compression; conversely a gamma value >
1 is called a decoding gamma and the application of the expansive power-law nonlinearity is called gamma expansion.
Gamma compression, also known as gamma encoding, is used to encode linear luminance or RGB values into video signals or digital video file values; gamma expansion is the inverse, or decoding, process, and occurs largely in the nonlinearity of the electron-gun current–voltage curve in cathode ray tube (CRT) monitor systems, which acts as a kind of spontaneous decoder. Gamma encoding helps to map data (both analog and digital) into a more perceptually uniform domain.
The following figure shows the behavior of a typical display when image signals are sent linearly (γ = 1.0) and gamma-encoded (standard NTSC γ = 2.2). In the first case, the resulting image over the CRT is notably darker than the original, while it is shown with high fidelity in the second case. Digital cameras produce, and TV stations broadcast, signals in gamma-encoded form, anticipating the standardized gamma of the reproducing device, so that the overall system will be linear, as shown on the bottom; if cameras were linear, as on the top, the overall system would be nonlinear. Similarly, image files are almost always stored on computers and communicated across the Internet with gamma encoding.