Average
Apply average filter to image
1. imgAverage d:=20;
2. imgAverage d:=2 img:=mat(1) oimg:=mat(2);
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Dimension | d |
Input int |
|
Specifies the size of the averaging neighborhood, which is a square. This variable is the length, in pixels, of one side of the square. |
Input Matrix | img |
Input Image |
|
Specifies the image to be manipulated. The default input is the active image. |
Output Image | oimg |
Output Image |
|
Specifies the output image. By default, the output image is the same as the input image. See the syntax here. |
This function applies average filter to the input image so the color of each pixel is replaced by the average color of pixels in its neighborhood. This results in a blurring effect.
The user can control the amount of blur by specifying the size of the neighborhood that will be used in the averaging. Generally, the larger the size, the greater the blurring will be.
Successive use of the same command will further blur the image, as the image averaging now applies to the latest version of the image being averaged.
In this example, we use the imgAverage function to blur the input image:
This is an easy to implement method of color-averaging images that can be described by the equation:
where:
O(x, y) = the output image,
I(x, y) = the input image, and
d = the dimension specified by the user
For example, we need to average an image with a 3x3 window (d =3). Pixels of image section under the window we specified are shown below:
According to the algorithm above, the result value of center pixel in the window is
Where I(x,y) is the original value of the pixel which is in x row, y column of the Matrix.
The computation in Origin is implemented with the L_AverageFilterBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_AverageFilterBitmap topic.
LEADTOOLS Main API Help file, Version 14