Guest User

Untitled

a guest
Apr 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #Generate k random matrix points from image matrix
  2. #The input object IMAGE is assumed to be your intensity matrix
  3. #The output is a k x 2 matrix of coordinates for each of k coordinates
  4.  
  5. GENERATE <- function(IMAGE, k) { n <- nrow(IMAGE);
  6. m <- ncol(IMAGE);
  7. OUTPUT <- data.frame(Row = rep(0,k),
  8. Column = rep(0,k));
  9. RAND <- sample(1:(n*m), size = k, replace = TRUE,
  10. prob = as.vector(IMAGE))
  11. OUTPUT$Row <- 1 + RAND %/% n;
  12. OUTPUT$Column <- RAND %% n;
  13. OUTPUT }
Add Comment
Please, Sign In to add comment