Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.87 KB | None | 0 0
  1. #make the columns and fill them up with 0s
  2.  
  3. #csvdir = choose.dir(default = "C:/", caption = "Select the folder containing your CSV files")
  4.  
  5. csvdir = "C:/Users/sil/Desktop/trash/"
  6.  
  7. #gridx = as.integer(readline(prompt="Input the number of stacks in the horizontal direction: "))
  8. #gridy = as.integer(readline(prompt="Input the number of stacks in the vertical direction: "))
  9.  
  10. gridx = 5
  11. gridy = 5
  12.  
  13. stitched_a = matrix(0, nrow = 1024*gridy, ncol = 1024*gridx, byrow = TRUE) #change 1024 for images with a different resolution
  14.  
  15. n=1
  16. y=gridy
  17.  
  18. for (i in 1:gridy) {
  19.   for (j in 1:gridx) {
  20.     raw_a = read.csv(paste0(csvdir, n, ".csv"))
  21.     for (k in 1:nrow(raw_a)){
  22.       newx = 1024*(j-1) + round(raw_a[k,8])
  23.       newy = 1024*(y-1) + round(raw_a[k,9])
  24.       stitched_a[newy,newx]=+1
  25.     }
  26.     n=n+1
  27.   }
  28.   y=y-1
  29. }
  30.  
  31.  
  32. write.csv(stitched_as, paste(csvdir, "/stitcheda.csv")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement