Erratum in the "The art of R programming" Chapter3
blurpart <- function(img,rows,cols,q) { # img: image passed, rows: rows to edit, cols: col to edit, q: weight
lrows <- length(rows)
lcols <- length(cols)
newimg <- img
randomnoise <- matrix(nrow=lrows, ncol=ncols,runif(lrows*lcols)) # runif(): uniform dist.
newimg@grey <- (1-q) * img@grey + q * randomnoise
return(newimg)
}
shoud be modified to ;
blurpart <- function(img,rows,cols,q) {
lrows <- length(rows)
lcols <- length(cols)
newimg <- img
randomnoise <- matrix(data=runif(lrows*lcols), nrow=lrows, ncol=lcols)
newimg@grey[rows, cols] <- (1-q) * img@grey[rows, cols] + q * randomnoise
return(newimg)
}
'Learning & Reasoning > R ' 카테고리의 다른 글
alternative implement "The art of R programming" - 3.4.2 Extended Example (0) | 2013.02.13 |
---|---|
Erratum in "The art of R programming" Chapter 2 - abalone.data (1) | 2013.02.11 |
vector라 불리는 R 자료구조 (0) | 2013.02.06 |
AdaBoost (0) | 2013.02.01 |
random forest (0) | 2013.01.28 |