Proč ve foreach? Vygeneruj si náhodný index, pomocí něho vyber příslušný rectangle a s ním si dělej, co chceš.