The term you’re looking for is afterimage.

In vision science, an afterimage is the visual sensation that continues even after the original stimulus (like a bright light or a colored shape) is removed. For example, if you stare at a bright object and then look at a blank wall, the “ghost” of that object you still see is an afterimage.