Matrox imaging Library (MIL) edge detection module

      Record some of the process of learning the MIL image processing library.

In Edge Finder source code:

 // 分配一个边缘检测缓存.
 MIL.MedgeAlloc(MilSystem, MIL.M_CONTOUR, MIL.M_DEFAULT, ref MilEdgeContext);

// 分配一个结果缓存.
MIL.MedgeAllocResult(MilSystem, MIL.M_DEFAULT, ref MilEdgeResult);

// 下面这两句是自定义计算一些边缘特征:M_MOMENT_ELONGATION和M_FERET_MEAN_DIAMETER
MIL.MedgeControl(MilEdgeContext, MIL.M_MOMENT_ELONGATION, MIL.M_ENABLE);
MIL.MedgeControl(MilEdgeContext, MIL.M_FERET_MEAN_DIAMETER + MIL.M_SORT1_DOWN, MIL.M_ENABLE);

// 计算边缘和特征
MIL.MedgeCalculate(MilEdgeContext, MilImage, MIL.M_NULL, MIL.M_NULL, MIL.M_NULL, MilEdgeResult, MIL.M_DEFAULT);

// 返回获取的边缘数量.
MIL.MedgeGetResult(MilEdgeResult, MIL.M_DEFAULT, MIL.M_NUMBER_OF_CHAINS + MIL.M_TYPE_MIL_INT, ref NumEdgeFound);

// 绘制边缘轮廓到图中。
MIL.MgraColor(MIL.M_DEFAULT, EdgeDrawColor);
MIL.MedgeDraw(MIL.M_DEFAULT, MilEdgeResult, GraphicList, MIL.M_DRAW_EDGES, MIL.M_DEFAULT, MIL.M_DEFAULT);

     The above code only introduces the general steps of edge detection, and there are still many parameters that need to be modified that need to be changed with the actual image. The following is an introduction to the most commonly used MedgeControl in Edge:

       MedgeControl Description This function sets the specified control for the edge finder context or edge finder result buffer. For Edge Finder contexts, these settings control the execution of the MedgeCalculate operation and select which edge features MedgeCalculate should calculate. For Edge Finder result buffers, these settings control post manipulation of results. For example, to paint the scaled region of the source image used to compute the result, the paint control values ​​must be set appropriately.

 MedgeControl parameters: 

MIL.MedgeControl(MilEdgeContext, X, Y);//X, Y represent two parameters

X describe Y describe
M_ACCURACY Set the precision of edge extraction

M_DISABLE

M_HIGH

DISABLE means disabled and will be calculated with pixel precision.

HIGH means to specify very high sub-pixel precision to calculate.

M_ANGLE_ACCURACY  Sets the accuracy of corners during edge detection

M_HIGH

M_LOW

Just take it literally
M_CHAIN_ALL_NEIGHBORS  How to set up the edge chain

M_DISABLE

M_ENABLE

Controls whether to enable this parameter, which means to use more information to build edges. As shown below.

X describe Y describe
M_DETAIL_LEVEL Set the detail level of image extraction, the lower the detail level will find more edges, of course, these edges are not necessarily accurate.

M_HIGH

M_MEDIUM

M_VERY_HIGH

Set the level of detail to medium, high, and very high.
M_FILTER_SMOOTHNESS Set the smoothness processing of the image, that is, the degree of denoising. If it is too large, it will change the edge information of the image, and if it is too small, it will not be able to remove noise. This value needs to be set reasonably. (great impact on edge detection)

M_DEFAULT

VALUE

The default value is 50, and the setting range of VALUE is [0, 100]
M_FILTER_TYPE Set the operator for edge detection. The default operator used in MIL is SHEN-CASTAN, which is the heavy operator.

M_DERICHE

M_FREI_CHEN

M_PREWITT

M_SHEN

M_SOBEL

For several common operators, give a formula in the figure below.

X describe Y describe
M_FLOAT_MODE Sets whether to force all processing of edges to be computed using floating point precision.

M_DISABLE

M_ENABLE

none
M_MAGNITUDE_TYPE Sets how the magnitude of the edge gradient magnitude is computed at each edge. For CONTOUR, magnitude is the norm of the edge position gradient vector. CREAST is the maximum value of edge positions.

M_NORM

M_SQR_NORM

Default: M_SQR_NORM for contour and M_NORM for CREAST.

M_NORM refers to the gradient magnitude, and M_SQR_NORM refers to the square of the gradient magnitude.

M_OVERSCAN Set the scan type for processing boundary images (IIR filter, this parameter will be ignored, such as SHEN and deriche)

M_DISABLE

M_MIRROR

I don't understand this parameter

 There are many more, let’s write here first. Slowly add later~  

Guess you like

Origin blog.csdn.net/qq_37925923/article/details/132576806