# 18.9.2 Algorithms (Matrix Smoothing)

Matrix smoothing is done by shrinking and expanding the matrix. The order of shrink/expand operations depends upon matrix dimensions:

• If either the number of columns or rows is less than or equal to 31: The matrix is first expanded so that the row number and the column number are both twice that of the original. Then the expanded matrix is shrank to the original size.
• If both the number of columns and rows is greater than 31: The matrix is first shrank and then expanded to the original size.
• The matrix expansion is implemented by the mexpand X-Function (biquadratic interpolation is used).
• The matrix shrinking is done by the mshrink X-Function. The average value of N adjoining cells (N = Column Factor x Row Factor with default = 4) is calculated to obtain each cell value of the output matrix. Through this process of expanding and shrinking, the size of the output matrix will be exactly the same as the original matrix but the data will be smoothed.