| MIL 10 Reference
| Customize Help
| Save Settings

MimLocatePeak1d



See also
Availability
Not available in MIL-Lite
Available in MIL

Available on Windows
Available on Linux

Available on Non-Matrox computer
Available on Matrox 4Sight-X
Available on Matrox 4Sight GP
Available on Matrox Supersight
function map Function map
Examples
Synopsis
Performs peak intensity detection in every lane (row or column) of the source image.
Syntax
void MimLocatePeak1d(
MIL_ID ContextId, //in
MIL_ID SrcImageBufId, //in
MIL_ID ResultId, //in
MIL_INT PeakWidthNominal, //in
MIL_INT PeakWidthDelta, //in
MIL_DOUBLE MinContrast, //in
MIL_INT64 ControlFlag, //in
MIL_DOUBLE ControlValue //in
)
Description

This function detects the position and the intensity of a peak in every lane (row or column) of an image. It is well suited for applications that generate 3D data based on laser line or sheet of light profiling.

The function iterates through each lane. For each lane, the function determines the pixels that are in the peak neighborhood, as defined by PeakWidthNominal, PeakWidthDelta, and MinContrast. For each such region, it finds the position of the highest intensity with sub-pixel accuracy, and calculates the average intensity around that position. The position can be retrieved in a fixed-point representation, with 0 to 7 fractional bits.

For optimal performance, preprocess the result buffer by calling MimLocatePeak1d() with M_PREPROCESS. You can choose to preprocess with or without an image. When preprocessing with an image, specify a typical image in the series of images that you will process with MimLocatePeak1d(). The preprocessed image's size and bit-depth are stored. When preprocessing without an image (SrcImageBufId set to M_NULL), you must specify the number of scan lanes in a typical image in the series with ControlFlag. When preprocessing without an image, it is assumed that all images are 8-bit unsigned.

If the preprocess operation is not done explicitly (using M_PREPROCESS) or correctly, MimLocatePeak1d() will preprocess the result buffer internally when it is first called. If a new image in the series has a different size or bit-depth than the image used to preprocess, MimLocatePeak1d() will preprocess the result buffer again, given the new image's characteristics.

In a noisy image, or any image that might have multiple peaks in a single lane, such as when the object or surface is highly reflective, MimLocatePeak1d() can record the position and intensity of multiple peaks in a lane. You can create custom applications that sift through the multiple peaks in each lane to determine the best peak in the lane for your needs. To record multiple peaks in a lane, use MimControl() with M_NUMBER_OF_PEAKS set to the maximum number of peaks to record. For more information, see the Multiple peaks in a single lane subsection of the Peak intensity detection and depth maps section of Chapter 4: Advanced image processing.

You can retrieve the calculated results from the result buffer using MimGetResultSingle().

For results obtained from laser line images, you can draw an uncorrected depth map or intensity map using MimDraw() with M_DRAW_DEPTH_MAP_ROW or M_DRAW_INTENSITY_MAP_ROW, respectively. For more information, see the Generating an uncorrected depth map subsection of the Peak intensity detection and depth maps section of Chapter 4: Advanced image processing.

To verify that the peak was found at the right location, you can draw the calculated peak intensities at the calculated positions into an image buffer using MimDraw() with M_DRAW_PEAKS.

Note that this function reference has not been updated for a MIL system added during a MIL update. Refer to the MIL system's release note to see if there is complementary information.
Parameters
This function is not supported on the selected boards.
Parameters
ContextId

Specifies the identifier of the image processing context.

The image processing context must have been previously allocated using MimAlloc() with M_LOCATE_PEAK_1D_CONTEXT.

SrcImageBufId

Specifies the identifier of the source image buffer.

Note that this function only supports 8- and 16-bit unsigned source image buffers.

This image buffer must not have a region of interest (ROI) associated with it. Using an image buffer with an ROI will cause an error.

This image buffer must not have an associated calibration context. Using an image buffer with an associated calibration context will cause an error.

When preprocessing (M_PREPROCESS), you can specify an image in the series, or you can set this parameter to M_NULL.

ResultId

Specifies the identifier of the image processing result buffer in which to store results. The result buffer must have been allocated using MimAllocResult() with M_LOCATE_PEAK_1D_RESULT.

PeakWidthNominal

Specifies the nominal (expected average) width of the peak neighborhood. In laser line images, this is the average width of the laser line.

function map For specifying the nominal width of the peak
CollapseValue Description
Collapse M_DEFAULT

Specifies to use the value of the control type M_PEAK_WIDTH_NOMINAL, set using MimControl(). The default value of M_PEAK_WIDTH_NOMINAL is 20.

(summarize)
Collapse M_NULL

Specifies to ignore this parameter. This setting should be used exclusively when ControlFlag is set to M_PREPROCESS; this is the only possible setting in this case.

(summarize)
Collapse Value > 0

Specifies the average width, in pixels.

PeakWidthDelta

Specifies the number of pixels that can be added to or subtracted from the nominal width, when determining the range of allowable widths of the peak neighborhood.

PeakWidthNominal plus PeakWidthDelta defines the maximum width of the peak neighborhood. PeakWidthNominal minus PeakWidthDelta defines the minimum width of the peak neighborhood.

function map For specifying the variance of the width of the peak
CollapseValue Description
Collapse M_DEFAULT

Specifies to use the value of the control type M_PEAK_WIDTH_DELTA, set using MimControl(). The default value of M_PEAK_WIDTH_DELTA is 20.

(summarize)
Collapse M_NULL

Specifies to ignore this parameter. This setting should be used exclusively when ControlFlag is set to M_PREPROCESS; this is the only possible setting in this case.

(summarize)
Collapse Value > 0

Specifies the maximum amount of variance from the nominal width, in pixels.

MinContrast

Specifies the minimum contrast (difference) between the intensity of the local background and the minimum acceptable intensity of pixels in the peak neighborhood.

function map For specifying the contrast that defines the peak
CollapseValue Description
Collapse M_DEFAULT

Specifies to use the value of the control type M_MINIMUM_CONTRAST, set using MimControl(). The default value of M_MINIMUM_CONTRAST is 100.

(summarize)
Collapse M_NULL

Specifies to ignore this parameter. This setting should be used exclusively when ControlFlag is set to M_PREPROCESS; this is the only possible setting in this case.

(summarize)
Collapse 0 <= Value <= 65534

Specifies the minimum difference in intensity.

Note that the default value is 100, regardless of the bit depth of the image. To keep the default functionality in a 16-bit image, set this value to 25,600.

(summarize)
ControlFlag

Specifies whether to explicitly preprocess the image processing result buffer.

function map For specifying whether or not to preprocess
CollapseValue Description
Collapse M_DEFAULT

Specifies to perform the peak intensity detection on the specified image.

When the specified image processing result buffer has not been preprocessed or has been preprocessed with an image that has different characteristics than SrcImageBufId, (for instance, size or bit depth) MimLocatePeak1d() will automatically preprocess the image processing result buffer before performing the peak intensity detection.

(summarize)
Collapse M_PREPROCESS

Specifies to preprocess the specified image processing result buffer.

ControlValue

Specifies the number of scan lanes in subsequent source images, when preprocessing without an image (ControlFlag set to M_PREPROCESS and SrcImageBufId set to M_NULL).

In all other cases, set this parameter to M_DEFAULT.

Compilation information
Header Include mil.h.
Library Use mil.lib; milim.lib.
DLL Requires mil.dll; milim.dll.
LOCATE PEAK 1D CONTEXT NULL UNSIGNED PROC NONE DEFAULT NULL DEFAULT NULL DEFAULT NULL DEFAULT PREPROCESS