A profile plotted over its source image is useful only when its position and amplitude have explicit meanings. Plotting channel values directly uses intensity as a vertical coordinate, which usually places the curves somewhere unrelated to the measurement line. Independently normalizing the channels can also hide real differences between them.
For engineers building inspection displays, the reliable approach is to keep sampling coordinates, measured intensities and drawing coordinates separate. You will define a baseline, convert intensity into display height, and verify the overlay against known positions without modifying the source measurements.
Define the coordinate and intensity contracts
Use one coordinate convention throughout acquisition, sampling and drawing. In a one-based pixel-center convention, the upper-left pixel center is (1, 1). The lower-right center is (W, H), where W and H are image width and height. A zero-based convention works equally well, provided every operation follows it.
For the examples below, image coordinates increase rightward and downward. A curve extending upward must therefore subtract its display height from its baseline coordinate. Preserve equal horizontal and vertical image-coordinate scaling so that drawn geometry is not stretched.
Keep three arrays conceptually separate:
- Sample positions: the image coordinates where measurements were taken.
- Measured values: the unmodified channel intensities at those positions.
- Overlay positions: coordinates calculated only for drawing the curves.
Confirm that your input is a decoded image array, not an encoded file buffer. The image bytes versus pixel data explanation covers that distinction.
Also decide what the measurements represent. RGB code values are not automatically linear measurements of optical power. Camera processing, encoding and exposure settings can change their relationship to scene brightness. An overlay can faithfully display code values without claiming calibrated radiometry.
Establish sampling positions before drawing
-
Choose a measurement line inside the image. For a horizontal profile, specify its left endpoint, right endpoint and row coordinate. Do not start at coordinate zero when using one-based pixel centers.
-
Choose the sampling method. Sampling every pixel center avoids interpolation along an axis-aligned row. Fractional positions require a documented interpolation method. Bilinear interpolation can return fractional intensities even when stored pixels are integers.
-
Retain the actual sample coordinates. Use coordinates returned by the sampler, or generate the coordinates explicitly and sample at those positions. Do not substitute sample index for horizontal image position.
For a straight line with endpoints p0 and p1, equally spaced positions can be generated as follows:
Suppose an image is 1024 pixels wide and you request 512 samples between horizontal coordinates 1 and 1024. The sample spacing is (1024 - 1) / (512 - 1) = 1023 / 511, approximately 2.002 image pixels. Drawing those values at horizontal coordinates 1 through 512 compresses the profile into roughly half the image width.
If averaging several rows would make the measurement more stable, first follow the row-summing intensity profile method. That changes how the profile is measured; the coordinate mapping here still determines where it is drawn. Label an averaged or summed band rather than implying that it represents a single row.
Set a baseline and a shared display-height scale
-
Place the baseline at the measurement line. For a horizontal line, let its vertical coordinate be
y0. Draw the baseline separately so viewers can identify the sampling location beneath the curves. -
Choose an intensity reference and display height. Let
I_lowandI_highdefine a shared intensity range. Lethbe the image-coordinate height assigned to that range. These are display settings, not changes to the measurements. -
Transform each channel with the same scale. In downward-increasing image coordinates, use the following mapping:
Here, c identifies a channel and s has units of image pixels per intensity unit. A value equal to I_low sits on the baseline. A value equal to I_high sits h image pixels above it.
Use a fixed acquisition range when comparing captures quantitatively. A shared range calculated from the current image can help exploration, but the same physical scene may then appear with different curve heights between frames.
| Scale choice | What it preserves | Appropriate use |
|---|---|---|
| Fixed shared channel range | Channel relationships and consistent height between captures | Inspection trends and repeatable displays |
| One shared range from the current capture | Channel relationships within that capture | Exploratory viewing with visible range labels |
| Separate range for each channel | Individual curve shape, but not relative channel magnitude | Shape-only analysis, explicitly labeled |
Work through a horizontal RGB example
Consider a hypothetical 1024 × 600 image containing unsigned 8-bit RGB values. Sample a horizontal line at y0 = 300, and retain each sample's horizontal image coordinate. Choose a display height of 120 image pixels and a common intensity range from 0 to 255.
The arithmetic is:
At one sampled location, suppose the channel values are red 204, green 128 and blue 51. Their plotted coordinates are:
| Channel | Measured intensity | Height above baseline | Plotted vertical coordinate |
|---|---|---|---|
| Red | 204 | 96 pixels | 204 |
| Green | 128 | About 60.2 pixels | About 239.8 |
| Blue | 51 | 24 pixels | 276 |
All three points keep the same horizontal sample coordinate. Their vertical displacement communicates intensity, not the location of another feature in the image. The strongest channel is drawn highest because image vertical coordinates increase downward.
A zero value remains at coordinate 300, while a value of 255 reaches coordinate 180. This provides two immediate reference checks. Label the display with the baseline, the range 0–255, and the chosen height of 120 image pixels.
The height is a drawing convention, not a physical distance. Changing it changes readability but must not change any reported intensity measurement.
Implement the overlay without changing the measurements
Keep the original image and sampled values available for processing and export. Build overlay coordinates in separate arrays, then draw the image, baseline and curves in that order.
The following language-neutral pseudocode makes the separation explicit:
image = read_decoded_image()
positions = make_line_positions(start, end, sample_count)
measured = sample_rgb(image, positions, interpolation_method)
assert I_high > I_low
scale = display_height / (I_high - I_low)
show_image_in_image_coordinates(image)
set_equal_coordinate_aspect()
set_vertical_coordinates_increasing_downward()
keep_image_extent_fixed()
draw_measurement_line(start, end)
for channel in red, green, blue:
draw_x = positions.x
draw_y = baseline_y - scale * (measured[channel] - I_low)
draw_polyline(draw_x, draw_y, channel_color)
show_scale_label(I_low, I_high, display_height)
Perform subtraction and multiplication in a suitable floating-point type. Unsigned integer arithmetic can underflow when a value falls below the chosen reference. Floating-point drawing coordinates also avoid unnecessary rounding of interpolated samples.
If the display framework automatically rescales axes after adding graphics, restore the original image extent. Otherwise, the curves can change the apparent image size or introduce empty margins.
Use a legend and a contrasting baseline. Thin channel curves usually obscure less inspection detail than filled areas. For masks, labels and opacity handling, the image overlay guide explains how to keep annotations separate from image content.
Verify alignment and handle nonhorizontal lines
Start with synthetic checks before trusting a production display:
- Constant values: every channel should form a straight line at its calculated height.
- A horizontal ramp: curve position should progress smoothly from the first sample coordinate to the last.
- One bright column: the profile peak should align with that column, subject to the chosen sampling and interpolation.
- A channel-only target: only the corresponding channel should rise above a zero baseline.
Check both line endpoints after zooming or resizing. If the overlay shifts while the image moves correctly, the graphics may be using window coordinates rather than image coordinates. Apply the same image-to-window transform to both.
For an oblique line, displace each sampled point along a unit normal rather than subtracting from its vertical coordinate alone. Let the line direction be (dx, dy):
For a left-to-right horizontal line, this normal points upward in the stated image convention. Reversing the endpoints reverses the normal, so choose and label a consistent side. Each point's projection onto the measurement line retains its sampling position.
Keep acquisition choices separate from display choices
The overlay method does not require a particular camera interface. Before replacing hardware, verify decoding, sample locations, numeric types and drawing transforms. Use the area scan cameras category and camera finder only when acquisition requirements also need attention.
The LS-CMR-0053 is one acquisition candidate to assess against your image-format and integration requirements.
- Sensor format
- 1/1.7"
- Lens mount
- C-mount
- Interface
- GigE
- Resolution
- 12 MP
The LS-CMR-0166 provides another candidate for that assessment. Neither selection removes the need to verify channel order, supported output formats and application compatibility.
- Sensor format
- 1/1.7"
- Interface
- USB3
- Resolution
- 12 MP
- Shutter
- Rolling
For an integrated inspection station, evaluate vision controllers against acquisition support, processing workload and display integration. Port availability alone does not establish whether the complete pipeline meets its timing requirements.
Retain the original sample depth when comparing captures. The guide to saving camera images without losing intensity data explains why a convenient display export may not preserve the measurements you intend to analyze.
Recognize when a different display is better
An overlay is useful for spatial correlation, but it is not always the clearest quantitative chart. A high baseline, a large display height or values outside the chosen range can push curves beyond the visible image.
Reduce the display height, move the measurement line if the task permits, or use a separate profile chart with explicit intensity axes. Do not silently clip values or rescale each channel to make everything fit. If rendering is clipped, mark that condition and retain the original measurements.
A zero-referenced display may make small variations difficult to see on a bright background. A signed display around a fixed reference can reveal deviations, provided the label identifies that reference. Negative displacement then means below-reference intensity, not negative optical power.
When comparing captures, hold exposure, gain and relevant image processing settings constant, or record their changes. Correct overlay geometry cannot compensate for a changing acquisition pipeline.
Check the display before release
Use this short acceptance checklist:
- Confirm the coordinate origin, pixel-center convention and vertical direction.
- Draw curves at actual sample positions, not array indices.
- Keep measured values separate from drawing coordinates.
- Apply one documented scale to all channels when comparing magnitude.
- Show the baseline, intensity reference and display-height mapping.
- Verify a constant field, a ramp and an isolated bright feature.
- Check zooming, resizing, clipping and export behavior.
- Preserve the source image and measurement metadata.
If acquisition also needs to change, start with the camera configurator. For help defining the measurement line, intensity range and acceptance checks, use application support with a representative image and your coordinate convention.
Questions
Why does my intensity curve appear away from the measurement line?
The horizontal coordinate must come from the measurement location, while the vertical coordinate combines a baseline with a scaled intensity. Plotting raw intensity against sample index skips both mappings. A mismatched coordinate origin or reversed vertical axis can introduce an additional shift or reflection.
Should RGB channels share the same display scale?
Use the same reference range and scale for every channel when comparing their magnitudes. Separate normalization is appropriate only for comparing shapes, because it removes relative amplitude information. For comparisons between captures, keep the shared range fixed rather than recalculating it for each image.
Does changing the overlay height change the intensity data?
No. Store the sampled values separately and calculate drawing coordinates from them. Increasing the display height should make the curves taller without affecting saved intensities, thresholds or statistics. Export measurements from the original arrays, not from coordinates recovered from the rendered curves.
Can I overlay a profile measured along a diagonal line?
Yes. Keep the sample coordinates along the line and displace each plotted point along a chosen unit normal. Maintain equal image-coordinate aspect and a consistent endpoint direction. Otherwise, the apparent displacement can be distorted or switch to the opposite side of the line.

