imnoise {SpatialPack} | R Documentation |
Add noise to image
Description
This function adds noise to an input image.
Usage
imnoise(img, type = "gaussian", mean = 0, sd = 0.01, epsilon = 0.05, var = 0.04,
looks = 1)
Arguments
img |
input grayscale image matrix. |
type |
character string, specifying the type of contamination: |
mean |
mean for the Gaussian noise, default value is |
sd |
standard deviation for the Gaussian noise, default value is |
epsilon |
contamination percentage for the salt and pepper noise with default noise
density |
var |
variance of uniform multiplicative noise using the equation |
looks |
parameter of gamma multiplicative noise. The default value is |
Value
Noisy image, returned as a numeric matrix. The imnoise
function clips output
pixel values to the range [0,1]
after adding noise.
Examples
data(texmos2)
x <- imnoise(texmos2, type = "saltnpepper", epsilon = 0.10)
plot(as.raster(x))
y <- imnoise(texmos2, type = "speckle")
plot(as.raster(y))
z <- imnoise(texmos2, type = "gamma", looks = 4)
plot(as.raster(z))