matrix.smooth {oce} | R Documentation |
Smooth a matrix.
matrix.smooth(m)
m |
a matrix to be smoothed. |
The values on the edge of the matrix are unaltered. For interior points, the result is defined in terms in terms of the original as follows. r_[i,j] = (2 m_[i,j] + m_[i-1,j] + m_[i+1,j] + m_[i,j-1] + m_[i,j+1])/6.
A smoothed matrix.
Dan Kelley
m <- matrix(rep(seq(0, 1, length.out=5), 5), nrow=5, byrow=TRUE) m[3,3] <- 2 m1 <- matrix.smooth(m) m2 <- matrix.smooth(m1) m3 <- matrix.smooth(m2) par(mfrow=c(2,2)) image(m, col=rainbow(100), zlim=c(0,4), main="original image") image(m1, col=rainbow(100), zlim=c(0,4), main="smoothed 1 time") image(m2, col=rainbow(100), zlim=c(0,4), main="smoothed 2 times") image(m3, col=rainbow(100), zlim=c(0,4), main="smoothed 3 times")