Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Generate k random matrix points from image matrix
- #The input object IMAGE is assumed to be your intensity matrix
- #The output is a k x 2 matrix of coordinates for each of k coordinates
- GENERATE <- function(IMAGE, k) { n <- nrow(IMAGE);
- m <- ncol(IMAGE);
- OUTPUT <- data.frame(Row = rep(0,k),
- Column = rep(0,k));
- RAND <- sample(1:(n*m), size = k, replace = TRUE,
- prob = as.vector(IMAGE))
- OUTPUT$Row <- 1 + RAND %/% n;
- OUTPUT$Column <- RAND %% n;
- OUTPUT }
Add Comment
Please, Sign In to add comment