Apply average filter to image
Command Line Usage
1. imgAverage d:=20;
2. imgAverage d:=2 img:=mat(1) oimg:=mat(2);
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
Specifies the size of the averaging neighborhood, which is a square. This variable is the length, in pixels, of one side of the square.
Specifies the image to be manipulated. The default input is the active 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:
- When the image is active, select Image: Spatial Filters: average to open the dialog of the X-Function.
- In the dialog, change the settings as the screenshot below and click OK to close the dialog.
A new image is created. It is the filtered image.
The original image
The output image
This is an easy to implement method of color-averaging images that can be described by the equation:
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