| Customize Help

Speeding up the search



There are some things you should do to help ensure that your search runs as quickly as possible:

  • Adjust the search speed of the algorithm.

  • Disable calculations specific to range search strategies, if possible.

  • Define several models with different expected angles.

  • Limit the position range.

  • Limit the search scale.

  • Specify the exact number of expected occurrences.

  • Clean up your model.

  • Change the search levels (for controlled geometric Model Finder contexts only).

  • Use an appropriate context type for your search.

Adjust the search speed of the algorithm

You can control the search speed of the algorithm used by your Model Finder context, using MmodControl() with M_SPEED. When you preprocess the context, MIL analyzes the patterns of the models and determines which shortcuts are appropriate for the search speed setting. At higher search speed settings, the search can take all reasonable shortcuts; therefore, when possible, the search is performed faster than at lower speeds. You can typically use higher speed settings when high accuracy is not an issue; this is because increasing the speed might affect the robustness and accuracy.

Disable calculations specific to range search strategies

If you expect that the occurrences sought are close to the specified nominal position, angle, or scale (for example, in a registration application), you can try disabling the calculations specific to the search strategies for the corresponding range (MmodControl() with M_SEARCH_POSITION_RANGE, M_SEARCH_ANGLE_RANGE, and/or M_SEARCH_SCALE_RANGE) to see if Model Finder can still find the required occurrences. Disabling one or more of these calculations might speed up the search depending on the model and the target.

Define several models with different expected angles

The actual angle of the occurrence does not affect search speed. If you need to search for a model at discrete angles only (for example, at intervals of 90 degrees), it is typically more efficient to define several models with different expected angles, than to search through the full angular range.

Limit the position range

Limiting the position range of the model to the minimum required generally decreases the search time. Set the position range of each model to the minimum needed, using MmodControl() with the M_POSITION_DELTA_NEG_X, M_POSITION_DELTA_NEG_Y, M_POSITION_DELTA_POS_X, and M_POSITION_DELTA_POS_Y control types. If the occurrence must be at a specific position, set these control types to zero.

Limit the search scale

It is best to set a fixed scale at which to search for occurrences of a model, instead of searching in a range. Sometimes, you must search for model occurrences that can vary in size; in these cases, enabling MmodControl() with M_SEARCH_SCALE_RANGE might be necessary. In these cases, keep the scale range as small as possible to avoid slowing down your search. You should not use the scale range to cover different expected scales at different positions. In this case, it is typically more efficient to define several models with different expected scales. This is because a large scale range could potentially slow down your operation; as well, you could find unwanted occurrences.

Specify the exact number of expected occurrences

If you know the exact number of occurrences for which to search, specify it using MmodControl() with M_NUMBER. This will typically reduce search time. If you search for more occurrences than required, the search might take longer than necessary.

Clean up your model and your target

Typically, reducing the number of unwanted edges in your models and your target will accelerate your search. There are several different ways to clean up your model and your target:

  • Reduce the noise. Noise in your models can cause inaccurate results. In addition, noise in your models and/or your target can also increase the length of time for a search. The most efficient way to reduce noise is to use the MmodControl() M_SMOOTHNESS and M_DETAIL_LEVEL control types. These affect all image-type models in your context, as well as the target when it is an image.

  • Use masking. You can use MmodMask() to mask regions of the model. Using MmodMask(), you can effectively remove areas of the model from consideration. This might help speed up your search.

  • Use the Edge Finder module. You can use the Edge Finder module to extract only the required edges from the image that you want to use as your model source or target, and then use the Edge Finder results as the model source or target instead.

  • Limit the number of active edgels MIL processes in the target. By calling MmodControl() with M_ACTIVE_EDGELS, you can adjust the degree to which MIL processes edgels in the target (MmodFind()) for a geometric (MmodAlloc() with M_GEOMETRIC) type of Model Finder context. The target edgels that MIL processes are considered active. By limiting the active edgels in the target, you can speed up the search. To draw the target's active edgels, use MmodDraw() with M_DRAW_ACTIVE_EDGELS.

Change the search levels

It is possible to speed up the search by adjusting the resolution levels for the search. This can be done using MmodControl() with M_FIRST_LEVEL and M_LAST_LEVEL. This should be done cautiously; their default setting (M_AUTO) determines the resolution levels automatically and usually provides the best results for the search operation.

Use an appropriate context type for your search

As has been discussed throughout this chapter, certain types of contexts have advantages and disadvantages with regards to the type of model being sought in the target. For instance, if the occurrences in a target vary in scale and have various distinct angles, an M_GEOMETRIC type of Model Finder context would be appropriate. Whereas, if the occurrences in the targets have a nominal difference in scale and angle, but have a high geometric complexity, the M_GEOMETRIC_CONTROLLED type of Model Finder context could be the most appropriate. When searching for general elliptical shapes, the M_SHAPE_ELLIPSE type of Model Finder context will search for a range of aspect ratios (M_MODEL_ASPECT_RATIO) relative to the nominal aspect ratio, and will typically provide better and/or faster results than the two previously mentioned context types. If the ellipses are in fact circles, the M_SHAPE_CIRCLE type of Model Finder context will typically provide better and/or faster results then the other types of contexts.