Mimic
Action – the human eye is evolved to detected motion and contrast. Things moving attract our attention as a potential threat to our own survival. And we look at contrast to pick out things that do not belong. Once detected the octopus has several choices. It can run. It usually tries to hide. And it can mimic its surroundings. This is done rapidly and colorfully to match itself to the surrounding coral.
But once you see it the color change is pretty obvious. I do admire the camouflage. Finally there is ink which can be squirted strategically to startle the pursuer. This actually worked upon me the first time I encountered this trick. This was the first octopus of the day and I got to see color changes.
No he did not surprise me. And in return I took his picture and did not eat him.