2.6.6.1 imgAverage
Menu Information
Average
Brief Information
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
Variables
Display Name
|
Variable Name
|
I/O and Type
|
Default Value
|
Description
|
Dimension
|
d
|
Input
int
|
2
|
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
|
<active>
|
Specifies the image to be manipulated. The default input is the active image.
|
Output Image
|
oimg
|
Output
Image
|
<input>
|
Specifies the output image. By default, the output image is the same as the input image.
See the syntax here.
|
Description
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.
Examples
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
|
Algorithm
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.
References
LEADTOOLS Main API Help file, Version 14
Related X-Functions
imgGaussian, imgMedian
|