ShowImage  Lab Report
Show RGB, HSV, HLS, or CMYK Color Coordinates, Planes and Histograms
ScreenShowImage.jpg (167021 bytes)
Shown above is the Hue space (of HSV color space) with fully saturated colors.

The purpose of this program, ShowImage.EXE, is to show RGB, HSV, HLS, or CMYK color coordinates, planes and histograms of an image. YIQ coordinates are displayed. A Print option allows the color separations or histograms to be printed for R, G, B, H, S, V and Intensity.  The number of unique RGB colors in an image is counted.

Materials and Equipment

Software Requirements
Windows 95
Delphi 3 or 4 (to recompile)
BMP, JPG, ICO, EMF, WMF file (GIFs can be used if you have a TGIFImage component. See below.)

Hardware Requirements
1024 x 768 display in high color or true color mode


  1. Double click on the magnifying glass icon, which represents the ShowImage.EXE program.
  2. Press the Read button and select an image to display. Press the Open button. (The directory from where you select an image will be saved in an .INI file for your next selection.)
  3. Select the desired color space, RGB, HSV, HLS or CMYK from the ColorSpace radiogroup. RGB color planes are shown as shades of of the color, or as shades of gray, when the Monochrome checkbox is selected. The Hue plane is shown with fully saturated colors. Other color planes are shown as shades of gray.
  4. Select the desired plane, which varies by the selected color space. The corresponding image and histogram should be displayed on the screen. The histogram bars are shown in color for R, G, B, and H and as shades of gray for other color planes.
  5. The Invert checkbox can be used at any time to invert the current image.
  6. The Stretch checkbox can be used to the image fills the available space.
  7. Press the Print button to see the various printing options:

    The "Big Image" and "Small Image" options print the image currently being displayed with two different sizes. The "Big Image" prints the image in landscape orientation with the image width 80% of the page (or adjusts the image to fit vertically). The "Small Image" prints the image in portrait orientation with the image width 40% of the page. A time stamp is printed at the lower left of both of these images.

    The "Color Spaces" option prints a full page with an array of images (R, G, B, Intensity, Lightness, H, S, V) in landscape orientation showing the various color planes. The shades-of- gray images represent values from 0 to 255.

    Note that for with Flower1.BMP image, the "dead" parts of the flower show up as low (dark) saturation values.
    (Note the "Hue" picture above has been changed to show the hue with color fully saturated.)

    The "Histograms" option prints a full page with an array of histograms (R, G, B, Intensity, Black, H, S, V) in landscape orientation, along with the original RGB composite image.

    Some areas of the histograms may only print correctly on color printers.
  8. Press the Save button at any time to save the image currently being displayed. A Save As dialog appears so you can save the BMP file where you want.

The program reads an image and interactively displays RGB composite image, or R, G, B, H, S, V, H, L, S, C, M, Y or K color planes. Note that Hue from HSV matches the Hue from HLS, but the Saturation from HSV is slightly different from the Saturation in HLS.

The OnMouseMove events for the ImageBig area report the pixel position (I,J) coordinates as you move the cursor, as well as a variety of color values for the pixel. RGB coordinates are shown from 0 to 255 or 0.000 to 1.000. Hue values are shown either from 0 to 255 or from 0 to 360 degrees. S, V, L values are shown from 0 to 255 or 0.000 to 1.000. C, M, Y, K values are shown only in the range from 0 to 255. Intensity and Lightness are reported from 0 to 255 or from 0.000 to 1.000. Y, I, Q values are computed from the 0.000 to 1.000 R, G, B values.

Print the image (or image plane) as "big" image in landscape orientation or "small" image in portrait orientation. Print the array of color spaces on single sheet. Print the array of histograms on single sheet. The histograms also show the following statistics: minimum, maximum, mean, standard deviation (except for "hue" where the statistics aren't meaningful).

ColorLibrary.PAS unit has various color conversion routines and support for creating histograms. The conversions in this library are appropriate only for one-way computations because of integer truncation in the final answer.. (For reversible computations using floating point values, look at the RealColorLibrary.PAS file.) StatisticsLibrary.PAS has a TDescriptiveStatistics class for calculating, min, max, mean and standard deviation of a series of numbers.

Images processed by ShowImage are assumed to have a 4:3 aspect ratio, e.g, 640 x 480. Color Space images may be stretched to fit if they have a different aspect ratio.

For GIF support you will need a GIF component such as TGIFImage from Anders Melander (or another source). Change the conditional compilation value from NOGIF to GIF and recompile once TGIFImage is installed. (You are responsible for any licensing with Unisys.)  The FormCreate method updates the OpenPictureDialog's filter to add GIF to the "all" group, as well as a separate GIF selection.

Images that are not 24-bits/pixel bitmaps are forced to be pf24bit TBitmaps so they can be processed by this program.

To count the colors in a 24-bits/pixel bitmap, use a 2D array of TBits objects.  When a (R,G) combination occurs for the first time, create an array of 256 bits in the blue dimension.  Set bits for each (R,G,B) combination and then count the number set.  For most images this is a fairly sparse array, but even with a completely filled-in 3D array of bits, this process is fairly fast.  See the CountColors function in the ImageProcessingPrimitives.PAS unit.

The Windows API calls GetCValue, GetMValue, GetYValue, GetKValue do not appear to work and were replaced with routines based on routines in Foley and Van Dam's computer graphcis textbook.  (10 Oct 2001)

The ShowImage program can be used to quickly analyze a large number of images, including various colors planes. The histograms can be used to analyze the contents of an image.

RGB (Red-Green-Blue)
HSV (Hue-Saturation-Value)
HLS (Hue-Lightness-Saturation )
CMYK (Cyan-Magenta-Yellow-Black), Intensity, Lightness
YIQ (intensity, chromaticity -- "Y" is the part of a color TV signal displayed on black-and-white sets)


TBits (used in CountColors)


OnMouseMove, Histogram (a frequency distribution), Color Plane, TDescriptiveStatistics, GetRValue, GetGValue, GetBValue, GetCValue, GetMValue, GetYValue, GetKValue, TIniFile, TColor

Delphi 3/4/5 Source and EXE (227 KB): ShowImage.ZIP

24-bit color BMP test image:
Parrots.ZIP (200 KB)

8-bit color BMP test image:
Deer.ZIP (28 KB) [note the "sparse" histogram with a 256-color image]

Update Notes
The October/November 1998 updates added the following features:

The January 2000 update:

Delphi 4 Conversion Notes

To avoid D4 compiler warnings with this program, the D3 code was modified for D3/D4 compatibility:

To avoid a runtime error when viewing the HSV histograms:

The Delphi 4 EXE is larger than the Delphi 3 EXE:
Delphi 3 EXE:  382 KB
Delphi 4 EXE:  478 KB
Delphi 5 EXE:  489 KB

Updated 26 Feb 2005

since 1 Nov 1998