If I have a grid of 50x50 rectangles how can I randomly place an image in only a few of them?

I could use a for loop for the amount of images but how do i make the random function match the exact location of the rectangles?

It would be good to see some code of yours

In theory you want to have an array (2D or 1D) to stire the information whether the cell has an image or not

If (grid [x][y]  == 1 ) {
   image(gridImage [x][y] , x*10,y*10);