Thanks for the tip, Jascha.
But today I discovered something. The iMac had more of these "seizures" than usual, and I got annoyed.
So I took the machine by its neck, and shook it. The screen was clear! The next time it happened I shook it again, and it worked. So each time there's some...