| Customize Help

Establishing a correlation



One way to find a model image in your source image is to use MimMatch(). This function establishes the correlation at every pixel in the target area of the source image between the pixel's neighborhood and a model image. The MimMatch() operation results in an image of correlation data. The closer the resulting pixel value is to the specified maximum possible score, the closer the match between the pixel's neighborhood in the target area and the model image. Other MIL match operations (such as, a pattern match using MpatFind() or MimMorphic()) don't produce the same types of results and don't necessarily use the same type of underlying correlation algorithm.

To store process settings, MimMatch() uses a match image processing context. You must set up the match image processing context with a model image, with which to perform the match, using MimControl() with M_MODEL_IMAGE. All other settings within the match image processing context are optional. By default a grayscale correlation is performed, using the entire model image with the maximum (match) score determined by the destination buffer type.

There are three different types of computation (modes) that can be performed when trying to match a model image to a source image neighborhood. These modes are set using MimControl() with M_MODE. The modes are:

  • Absolute sum of the differences. Calculates the correlation using the absolute sum of the difference between the source image and the model image, within the neighborhood.

  • Grayscale correlation. Calculates the correlation using a grayscale correlation.

  • Normalized correlation. Calculates the correlation using a normalized grayscale correlation.

When using the normalized grayscale correlation mode, you can specify how to compute the final score, using MimControl() with M_SCORE_TYPE. The options are:

  • To perform a normalized grayscale correlation.

  • To perform a square of the normalized grayscale correlation.

  • To perform one of the above and then clip the resulting value so that values less than 0 are set to 0.

Before calling MimMatch(), set up a match image processing context by performing the following:

  1. Allocate a match image processing context, using MimAlloc() with M_MATCH_CONTEXT.

  2. Specify the MIL image buffer containing the model image, using MimControl() with M_MODEL_IMAGE.

  3. Optionally, to reduce the size of the model image matched against the neighborhood of each pixel in the source image, specify a mask, using MimControl() with M_MASK_IMAGE. The part of the model that should be used in the match should contain zero values. All non-zero values are ignored.

  4. Optionally, set the type of computation to perform, using MimControl() with M_MODE (for example, correlation mode).

  5. Optionally, if using normalized grayscale correlation mode, specify whether to square or clip the final correlation score, using MimControl() with M_SCORE_TYPE.

  6. Optionally, specify whether to examine every pixel or every other pixel in the model image when matching, using MimControl() with M_MODEL_STEP. The former is slower but offers a more complete correlation.

  7. Optionally, if using the normalized grayscale correlation mode, specify the maximum final correlation score, using MimControl() with M_MAX_SCORE.

  8. Preprocess the context by calling MimMatch() with M_PREPROCESS. Both the source and/or destination image buffers can be set to M_NULL. If, however, the source or destination image buffer is provided, it should be a typical source or destination image buffer, respectively, and it will be used by the preprocess operation to better optimize future calls. If the preprocess operation is not done explicitly, it will be done when MimMatch() is first called.