Fundamentals of Computer Graphics Note 3 - Raster Images
Fundamentals of Computer Graphics Note 3 - Raster Images
- Raster displays show images as rectangular arrays of pixels .
- A vector image is described by storing descriptions of shapes—areas of color bounded by lines or curves.
Raster Devices
Images, Pixels, and Geometry
In the physical world, images are functions defined over two-dimensional areas—almost always rectangles. So we can abstract an image as a function
The pixel value is a local average of the color of the image, and it is called a point sample of the image. when we find the value x in a pixel, it means “the value of the image in the vicinity of this grid point is x.”
Coordinates of a four pixel × three pixel screen
A raster image is indexed by the pair (i, j) indicating the column (i) and row (j) of the pixel, counting from the bottom left. If an image has nx columns and ny rows of pixels, the bottom-left pixel is (0, 0) and the top right is pixel (nx - 1, ny - 1).
The rectangular domain of the image has width nx and height ny and is centered on this grid, meaning that it extends half a pixel beyond the last sample point on each side. So the rectangular domain of a nx × ny image is
Pixel Values
The values of pixels in terms of real numbers, representing intensity (possibly separately for red, green, and blue) at a point in the image.
Images should be arrays of floating-point numbers. the possible values in an 8-bit image are 0, 1/255, 2/255,. . . , 254/255, 1
Images stored with floating-point numbers, allowing a wide range of values, are often called high dynamic range (HDR) images to distinguish them from fixed-range, or low dynamic range (LDR) images that are stored with integers.
Reducing the number of bits used to store each pixel leads to two distinctive types of artifacts, or artificially introduced flaws, in images.
- Encoding images with fixed-range values produces clipping when pixels that would otherwise be brighter than the maximum value are set, or clipped, to the maximum representable value.
- Encoding images with limited precision leads to quantization artifacts, or banding, when the need to round pixel values to the nearest representable value introduces visible jumps in intensity or color.
Monitor Intensities and Gamma
All modern monitors take digital input for the “value” of a pixel and convert this to an intensity level. We assume a numeric description of pixel color that ranges from zero to one. Black is zero, white is one.
Two key issues:
- Monitors are nonlinear with respect to input.
- They take quantized input values.
Monitors are commonly characterized by a γ (“gamma”) value. This value is the degree of freedom in the formula
where a is the input pixel value between zero and one. Note that a = 0 maps to zero intensity and a = 1 maps to the maximum intensity regardless of the value of γ.
Once we know γ, we can gamma correct our input so that a value of a = 0.5 is displayed with intensity halfway between black and white. This is done with the transformation
So while we can manipulate intensities in the floating point range [0, 1], the detailed input to a monitor is a fixed-size integer. The most common range for this integer is 0–255 which can be held in 8 bits of storage. This means that the possible values for a are not any number in [0, 1] but instead
This means the possible displayed intensity values are approximately
where M is the maximum intensity.
RGB Color
In RGB additive color mixing we have
The color “cyan” is a blue-green, and the color “magenta” is a purple.
Alpha Compositing
The most important piece of information needed to blend a foreground object over a background object is the pixel coverage, which tells the fraction of the pixel covered by the foreground layer. We can call this fraction α. If we want to composite a foreground color cf over background color cb, and the fraction of the pixel covered by the foreground is α, then we can use the formula
The α values for all the pixels in an image might be stored in a separate grayscale image, which is then known as an alpha mask or transparency mask. Or the information can be stored as a fourth channel in an RGB image, in which case it is called the alpha channel, and the image can be called an RGBA image.
Popular image storage formats include: