I would swap in a different monitor (most newer TVs have computer inputs) and see what happens. If okay, you know the problem is with your monitor. If the same problem, you know it is with your computer.
This could be heat problem since you say it happens after running the computer for hours, and works again after being shut off for hours. So make sure the interior is clean of heat trapping dust and all fans spin properly. A failing power supply could also cause this (but so could a PSU full of heat trapping dust).