Hello and welcome.
That is usually a sign that the video card/logic board (depending on the exact model) is failing. Unfortunately that can be an expensive repair if your iMac is out of warranty at this point. If you have an external monitor you can hook up, try that. If the issue happens on the external as well, it is definitely the video card/logic board. If it doesn't, then it may be just the LCD panel, which is also an expensive repair.
Hope that helps,
C