- Forward


Images/Rasters
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Sampling Static Visual Content
Back SMYC Forward
  • Color Sampling:
    • Converting from a continuous "rainbow" of colors to a discrete finite palette of colors
    • Sometimes called quantization
  • Spatial Sampling:
    • Another name for spatial discretization
    • The most common scheme involves the use of a finite grid with equal size cells
Sampling Static Visual Content (cont.)
Back SMYC Forward
  • The Result:
    • A grid (or matrix) of picture elements (or pixels), each of which contains a single color in the palette
    • Sometimes called a raster representation
  • An Illustration:
    • raster
Operations
Back SMYC Forward
  • Single-Input/Single-Output Operations:
    • Some can be performed "in place" and some require a destination image
  • Multiple-Input/Single-Output Operations:
    • Are generally not performed "in place"
One Simple Operation - "Grayscale"
Back SMYC Forward
  • An Observation:
    • We want the "gray scale" to be the same brightness/luminance as the color image
  • What We Know:
    • Perceived luminance is a function of the total signal transmitted to the brain. So, \(R_g + G_g + B_g = R_c + G_c + B_c\)
    • Shades of gray are mixtures of black and white. So, \(R_g = G_g = B_g\)
  • The Implication:
    • \(R_g = G_g = B_g = (R_c + G_c + B_c) / 3 \)
Another Simple Operation - "Grayscale Except"
Back SMYC Forward
  • An Observation:
    • We probably want to keep colors that are "similar to" to the given color
  • Metrics and the Meaning of "Similar to":
    • A variety of different metrics can be used
    • Conceptually, one might want to use an HSV color model rather than an RGB color model
Look-Ups
Back SMYC Forward
  • Defined:
    • Use a look-up table to transform the source into the destination
  • Implementation:
    • Use an array in which the index corresponds to the possible colors in the source and the value in the array is the color to substitute
  • Types:
    • Use one array for all three components (i.e., the same look-up array for R, G, and B)
    • Use one array for each component (i.e., a different look-up array for R, G, and B)
Look-Ups (cont.)
Back SMYC Forward

An Example: A Photo Negative

for (int i=0; i<256; i++) { lookup[i] = (255 - i); }
Look-Ups (cont.)
Back SMYC Forward

An Example: A Night Vision Effect

for (int i=0; i<256; i++) { lookupR[i] = 0; lookupG[i] = i; lookupB[i] = 0; }
Color Space Conversion
Back SMYC Forward
  • Common Color Spaces:
    • RGB (an additive color model)
    • CMY (a subtractive color model)
    • HSV (hue in degrees, saturation in percent, value in percent)
    • HSL (hue in degrees, saturation in percent, lightness in percent)
    • YIQ (used by the National Television System Committee)
  • RGB\(\leftrightarrow\)CMY are Simple Conversions:
    • rgb-cube cmy-cube
Color Space Conversion (cont.)
Back SMYC Forward
An Example: RGB \(\leftrightarrow\) HSV

\( \left[ \begin{array}{c c} Y \\ I \\ Q \end{array} \right] = \left[ \begin{array}{r r r} 0.299 & 0.587 & 0.114 \\ 0.596 & -0.275 & -0.321 \\ 0.212 & -0.523 & 0.311 \\ \end{array} \right] \left[ \begin{array}{c c} R \\ G \\ B \end{array} \right] \)

\( \left[ \begin{array}{c c} R \\ G \\ B \end{array} \right] = \left[ \begin{array}{r r r} 1.000 & 0.956 & 0.621 \\ 1.000 & -0.272 & -0.647 \\ 1.000 & -1.105 & 1.702 \\ \end{array} \right] \left[ \begin{array}{c c} Y \\ I \\ Q \end{array} \right] \)

Cropping/Cutting
Back SMYC Forward
  • Defined:
    • Extraction of a rectangular "sub-image" from an image
  • Algorithm:
    • Should be obvious
There's Always More to Learn
Back -