Image Processing
PixelProfile.gif (1269 bytes) Pixel Profile  Lab Report
Display Pixel Profile Graph from 24-bit Color Image
ScreenPixelProfile.jpg (95177 bytes)

The purpose of this project is to display the pixel profile -- a graph of pixel values -- from two arbitrary points on an image.  The pixel profile graph can be of Red, Green, Blue values, or derived values Intensity, Hue, Saturation and Value.  A pixel profile may be useful in the analysis of an image.   For example, the pixel profile on the "Maize" image will be used to count the kernels of corn.

Materials and Equipment

Software Requirements
Windows 95/98
Delphi 3 or 4 (to recompile)

GIF Support:  Requires Anders Melander's TGIFImage and a "GIF" conditional to be set before compilation.  

Hardware Requirements
Super VGA display with 800-by-600 screen in high/true color display mode


  1. Double click on the PixelProfile.EXE icon to start the program.
  2. Click on the Load button and select an image (JPG, BMP, etc.) to analyze, such as the Maize.BMP file.  Select the Open button.
  3. With the Line Tool depressed, draw a line over an area of interest in the image, as shown in the screen above:  Press down on the mouse button, move, and then release the mouse button to draw a line.  This can be repeated any number of times, but only a single line can be drawn.  The Data and Graphs Tab Sheet only appear once the Pixel Profile line is drawn.
  4. If desired, use the Select Tool to move either of the end points of the line, or the entire line.  Again, press down on the mouse button, move, and then release.
  5. If desired, removed the line by pressing on the Erase Tool button.
  6. View the Pixel Profile data by selecting the Data Tab Sheet.  The (X,Y) coordinates shown in the data table are truncated to look up the R, G, B values of the pixels along the Pixel Profile Line.  Note that the first and last (X,Y) coordinates reflect the middle of the pixel location, e.g., (266.5, 311.5) to (348.5, 404.5) instead of (266, 311) to (348,404).

    The I=Intensity, H=Hue, S=Saturation, and V=Value values are computed from the R, G, B values.  Data can be cut from this screen for analysis in other applications.   (See Discussion below).

ScreenPixelProfileData.jpg (29178 bytes)

  1. Select the Graphs Tab Sheet to view the graphical Pixel Profiles.  Note the "Pixel Slice" is shown along the top of the graph.  Use the check boxes to select which graphs are shown.  Select the Print button to print the graph.

ScreenPixelProfileGraph.jpg (117650 bytes)

The data or graph provided by the Pixel Profile can be useful in analyzing an image.  For example, the number of kernels of corn (maize) in the image above can be determined by analyzing the Pixel Profile.

The data from the Pixel Profile shown above can be cut and paste into another application, or even saved to an ASCII text file using an editor.

This data can be imported into an Excel Spreadsheet.  The following shows the analysis of the the "Red" data profile:

ScreenPixelProfileSpreadsheet.jpg (36114 bytes)

The Index and Red columns are from the Data Tab Sheet shown above.  The Smooth column is the average Red[index-2], Red[index-1], Red[index], Red[index+1], Red[index+2], which is used to make the technique less sensitive to "noise" in the data. The Slope column is (Delta Y) / (Delta X), which in this case is simply Smooth[index] - Smooth[index-1].  The Sign column is the sign (-1, 0, +1) of the Slope column.  A peak is near the point where the slope changes from increasing (+1) to decreasing (-1).  The "1 -> -1" column identifies when a peak occurs.  In this image these "peaks" correspond to each kernel in the maize corn.

This is summarized in the following graph:

ScreenPixelProfileCountPeaks.jpg (42394 bytes)

All 15 peaks (i.e., kernels of corn) in the data were found using this technique.

Notes about the program:

See pixel profiles of a USAF 1951 Test Target, which is a way to quantify resolution of a system.

Example of using Pixel Profile as part of measuring modulation transfer function in article about understanding image sharpness.

The Pixel Profile is a useful tool to analyze color images. 

TChart, MouseDown/MouseMove/MouseUp, XOR Rubberband, Scanline, RGB, HSV, RGB/HSV Conversion, Intensity, TRGBTripleArray, TPicture, GraphicFilter, RestrictCursorToDrawingArea, RemoveCursorRestrictions, NearLine function

Delphi 3/4 Source and EXE (264 KB):  PixelProfile.ZIP

Special version for display of 1024-by-1024 images (Delphi 7 with Source):  PixelProfile1024.ZIP  [30 June 2003]
[NOTE:  Be sure to use a display of 1280-by-1024 or larger or you won't see the "Load" button on the right of the screen.]

Version of PixelProfile by MSDS to paste results to Excel spreadsheet (Sept 2004)

Updated 29 May 2007

since 21 Mar 1999