MimConvolve()函数

MimConvolve()卷积函数

Synopsis

Perform a general convolution operation.

Format

void MimConvolve(SrcImageBufId, DestImageBufId, KernelBufId)

MIL_ID SrcImageBufId;??? Source image buffer identifier
MIL_ID DestImageBufId;??? Destination image buffer identifier
MIL_ID KernelBufId;??? Kernel buffer identifier

Description

This function performs a general convolution operation on the source buffer using the specified kernel, storing results in the specified destination buffer.
The SrcImageBufId parameter specifies the identifier of the data source of the operation. This parameter must be given an image buffer identifier.
The DestImageBufId parameter specifies the identifier of the destination of the results. This parameter must be given an image buffer identifier.
The KernelBufId parameter specifies the identifier of the kernel buffer. This parameter can be given a custom or predefined kernel identifier. If you use a custom kernel, you must have previously allocated it with MbufAlloc1d or MbufAlloc2d and loaded it with values, using MbufPut.

Operation flags associated with custom kernels can be modified in order to control the behavior of the convolution operation. By using MbufControlNeighborhood you can control? how the operation handles the borders of an image (overscan), whether or not the absolute value of the result is taken, which division factor to apply to the result, whether or not to saturate the result, and the position of the kernel’s center.
The following is a list of predefined kernel buffer identifiers:

Default identifiers??? Corresponding kernels and their associated operation parameters
M_SMOOTH????? { {1,2,1},{2,4,2},{1,2,1} }? /16
M_SHARPEN??? { {-1,-1,-1},{-1,9,-1},{-1,-1,-1} }
M_SHARPEN2?? { {0,-1,0},{-1,5,-1},{0,-1,0} }
M_HORIZ_EDGE |{ {2,2,2},{0,0,0},{-2,-2,-2} }|
M_VERT_EDGE??? |{ {-2,0,2},{-2,0,2},{-2,0,2} }|
M_EDGE_DETECT??? (|{ {1,2,1},{0,0,0},{-1,-2,-1} }|? + |{ {-1,0,1},{-2,0,2},{-1,0,1} }|)/2
M_EDGE_DETECT2??? (|{ {1,1,1},{0,0,0},{-1,-1,-1} }|? + |{ {-1,0,1},{-1,0,1},{-1,0,1} }|)/2
M_LAPLACIAN_EDGE??? { {0,-1,0},{-1,4,-1},{0,-1,0} }
M_LAPLACIAN_EDGE2?? { {-1,-1,-1},{-1,8,-1},{-1,-1,-1} }
Operation flags associated to predefined kernels have the following default states: transparent overscan, results are saturated (saturation enabled), the kernel’s center pixel is the top left pixel of the central element in a neighborhood.
You can temporarily disable overscanning by adding M_OVERSCAN_DISABLE to a predefined kernel. For example, M_SMOOTH+M_OVERSCAN_DISABLE. This accelerates the convolution on certain platforms if the overscan data is not important in the resulting buffer.

If the source and destination are multi-band buffers then the same kernel is applied to every band of the source buffer.

Status

In-place processing is supported, but the source and destination image buffers cannot partially overlap (a situation that can only occur when using child buffers).

注:MimConvolve()函数用于图像处理邻域计算,用的数学卷积运算。可以用以定义好的核算子,也可以自己创建核算子。以下是测试滤波例子:

1.原图

2.M_SMOOTH????? { {1,2,1},{2,4,2},{1,2,1} }? /16
3.M_SHARPEN??? { {-1,-1,-1},{-1,9,-1},{-1,-1,-1} }
4.M_SHARPEN2?? { {0,-1,0},{-1,5,-1},{0,-1,0} }
5.M_HORIZ_EDGE |{ {2,2,2},{0,0,0},{-2,-2,-2} }|
6.M_VERT_EDGE??? |{ {-2,0,2},{-2,0,2},{-2,0,2} }|
7.M_EDGE_DETECT??? (|{ {1,2,1},{0,0,0},{-1,-2,-1} }|? + |{ {-1,0,1},{-2,0,2},{-1,0,1} }|)/2
8.M_EDGE_DETECT2??? (|{ {1,1,1},{0,0,0},{-1,-1,-1} }|? + |{ {-1,0,1},{-1,0,1},{-1,0,1} }|)/2
9.M_LAPLACIAN_EDGE??? { {0,-1,0},{-1,4,-1},{0,-1,0} }
10.M_LAPLACIAN_EDGE2?? { {-1,-1,-1},{-1,8,-1},{-1,-1,-1} }

LenaSmoothSharpenSharpen2HorizEdgeVertEdgeEdgeDetect,EdgeDetect2LaplacianEdgeLaplacianEdge2

《MimConvolve()函数》上有31条评论

评论已关闭。