Moving Average/Image Processing
Moving average applied on images[edit | edit source]
A weighted average is an average that has multiplying factors to give different weights to data at different positions in the sample window. Mathematically, the moving average is the convolution of the datum points with a fixed weighting function. One application is creating a pixelisation from a digital graphical image. For all the image on the right pixelisation is applied for several squares. All pixels in the square are replaced by the color average of all pixels in the square. Because colors are defined by three integer numbers so that color average must be rounded for that application. In order to understand color encoding with integer numbers see HTML Color Picker with the RGB color encoding. Three value between 0 and 255 (e.g. rgb(255, 153, 102) for light orange) encode a color. Due to the fact that the HTML colors for Red, Green, Blue (RGB) are integer numbers, the real values of the moving average are rounded as a technical constraint.
The image I with m pixels height and n pixels width is s matrix where all components of the matrix are RGB triples of integer values between 0 and 255, i.e. .
A single pixel at row r and column c is denoted as . If we define then the
- intensity of red is ,
- intensity of green is ,
- intensity of red is
If we calculate and average of colors, we calculate the average of red, green and blue separately. As an example we calculate an average of sub matrix of the image I for the four pixels:
The calculated moving average for this square is:
The calculate moving average for the sub matrix of the image I will replace all original colors of the square. Let the image with the moving average applied for all sub matrices, then the selected sub matrix above in IMA will look like this:
The last step assigns the calculated average color rgb(222, 84, 39) to all pixels of the 2x2-square submatrix.
Looking at the example image on right, the application of the moving average are visible, because they are applied on a large submatrix of the image.
For the image processing with the neutral element as an additive group with addition:
T is the set of all row and column indices of the pixels. The images is decomposed the squares or even rectangles . The moving average is calculated for all pixels in the rectangle similar to mentioned above. The calculated moving average from the original image I is assigned to all pixels of the square/rectangle in IMA. If the width and height of the rectangles have in general a default size. Close the borders of the images, the sizes of these rectangles have to be adapted to the remaining pixels at the right and bottom border of the image I.