dimanche 28 mars 2021

R large data frame random sub sample based on grid

I have a very large data frame (7000 columns and 14000) observations. They are in fact greyscale observations of each pixel of an image. 7000px observations on the x-axis and 140000px on the y axis. I'm looking for a way to do the following:

  • Divide the data frame into a grid that is 1000 by 1000 pixels (or 1000 cols and 1000 rows). In this case, it will be a grid of 7 by 14
  • Randomly select 1, 2, or more pixels from each grid
  • Store the returned values in a new data frame along with its x and y coordinates and if possible the grid it came from but this means numbering each grid as well.

Any ideas on how I might do this would be greatly appreciated




Aucun commentaire:

Enregistrer un commentaire