Previous Table of Contents Next


VIDEO.C next invokes DisplayFilteredImages() which produces 11 different filtered images using different algorithms. The algorithm FilterImageScanLine() used to filter individual scan lines depends on its input variable TypeFilter. DisplayFilteredImages() illustrates eight Laplacian edge enhanced images followed by three unsharp mask operations. The FilterImageScanLine() routine lists the specific 3x3 masks.

VIDEO.C then invokes DisplayEqualizedImage() to perform a histogram stretch operation. CreateEqualizationArray() creates equalization mapping values which DisplayEqualizedImage() uses to produce its output. CreateEqualizationArray() establishes a minimum intensity value by determining what intensity is greater than 1.5 percent of the total number of pixel values. It also establishes a maximum intensity value by determining what intensity value is greater than 98.5 percent of the total number of pixel values. CreateEqualizationArray() then uses a linear function (straight line drawn through the Cartesian coordinates (minimum, 0) and (maximum, 63)) to determine the values of the remaining 97 percent of the pixels.

VIDEO.C next performs a gamma correction for all palette entries by invoking FiddleWithPalette() which changes all screen pixel intensities nearly instantly. The initial gamma correction value is the current gamma correction value—GAMMA_CORRECTION_VALUE. The gamma correction value decrements to 1.25 and then increments to a value of 2.2 before decrementing down to GAMMA_CORRECTION_VALUE. Glancing at the horizontal bars beneath the histograms provides a visual representation of the effect of these gamma adjustments.

VIDEO.C then executes PerformScanLineProfileAnalysis(). This routine displays the individual pixel values for all pixels on each scan line in the histogram-stretched image by slowly sweeping a horizontal line down the image from top to bottom. The moving graph represents pixel intensities on the vertical axis and uses the horizontal pixel position as the horizontal coordinate.

VIDEO.C next displays numerous halftones using both ordered dither and error diffusion algorithms by invoking GenerateHalftones(). GenerateHalftones first loads the Borland Graphical Interface module EGAVGA.BGI by invoking BorlandGraphicsInit(). This routine switches the screen resolution to 640x480 graphics mode which has a 1:1 aspect ratio.

Using the Borland International graphics library routines allows the various halftone routines to use the Borland International C++ library routine putpixel() to emit a white or dark pixel. However, the aspect ratio change from 1:1.2 to 1:1 requires compensation (vertical stretching) to present the halftone images. The various halftone routines accomplish this by invoking LoadInterpolatedArrayLine() which assumes the source scan lines are expanded horizontally by a factor of four. To calculate the intermediate horizontal pixel intensity values between source image pixels, the routine uses linear interpolation. To calculate the intermediate vertical pixel intensity values, the routine interpolates between source input scan lines. The computations proceed as follows:

A VIDEO.C halftone routine produces an image with 384 horizontal pixels in each scan line (96 times 4) and almost 460 scan lines (96 times 4 times 1.2 for scaling). Before proceeding with a halftone iteration, a halftone routine invokes LoadInterpolatedArrayLine(), specifying what generated scan line should be loaded into its computation array. The scan-line number varies from 1 to almost 460. LoadInterpolatedArrayLine() divides the input number by 460.0 (for scaling) rather than 384 and multiplies the product by 96—the number of actual source image scan lines.

Suppose the product is 49.65, which is between 49 and 50. This indicates source image scan lines 49 and 50 should be used to generate the requested scan line. After horizontally interpolating both scan lines 49 and 50 to produce two interpolated scan lines with 384 pixels, the routine calculates how much each horizontally interpolated scan line contributes in the vertical interpolation step. In this instance, line 50 contributes 65 percent of the value and line 49 contributes 35 percent because the requested scan line is closer to line 50 than source line 49.

The GenerateHalfTones() routine first produces two threshold images using pixel intensities 16 and 18 as respective thresholds. It then invokes GenerateOrderedHalfTones() and GenerateDiffusedHalfTones() to generate a series of ordered and error diffusion images. In order, the 8x8 pixel algorithms ordered halftones are FineFattening, Bayer, VerticalLine, UpperLeftDown (135 degree), HorizontalLine, LowerLeftUp (45 degree), and CoarseFattening. The FineFattening, Bayer, VerticalLine, HorizontalLine, and CoarseFattening algorithms use Hewlett-Packard’s threshold arrays listed in Hewlett-Packard printer documentation. The LowerLeftUp and UpperLeftDown algorithms are derivations of the Hewlett-Packard HorizontalLine algorithm. Because the arrays assume pixel intensities from zero to 255, NormalizeArrays() divides each pixel threshold by 4 to generate pixel thresholds from zero to 63.

GenerateDiffusedHalfTones() invokes the following error diffusion routines in order:

  1. Stucki
  2. Adkinson
  3. Stevenson and Arce
  4. Sierra
  5. Jarvis, Judice, and Ninke
  6. Burkes
  7. Floyd Steinberg using integer calculations with no error loss
  8. Floyd Steinberg using integer calculations with 10 percent error loss
  9. IBM Corp.’s Floyd Steinberg with random error distribution
  10. Floyd Steinberg using a serpentine pattern
  11. Eschbach using integer calculations
  12. Floyd Steinberg with a concurrent Laplacian operation using integer calculations
  13. Eschbach using floating point calculations with no error loss
  14. Floyd Steinberg using floating point calculations with no error loss.

The various results are derived from the low-resolution, blurry image. VIDEO.C program ends by setting the resolution to 80x25 text mode and displaying a closing message.


Previous Table of Contents Next