Atleast from the organisms point, it must require thought since they have to see the background first.
Yes, well it depends how you define "thought". I've been pointing to other examples of animal reflexes for comparison with the camouflage for a reason. These reflexes could also be considered to be based in thought; for instance, your wincing reflex when something is near your eyeball is based on a visual perception, and a perception could be considered a thought. But if we're taking about conscious thoughts -- "I'd better close my eyelid in case this thing hits my eye" -- then obviously this kind of thought is not involved in a reflex.
So I don't believe that flounder and other camouflagers are creating their camouflage patterns consciously. Of course, their color-changing is also used for communication, and in these cases their state of mind is being expressed. Is this a thought? Well, humans also express themselves in various ways subconsciously while communicating. While our speech is a product of our higher mind, our body language, vocal stress, and facial expressions are a product of our underlying feelings. Similarly, when a squid "talks" to another squid with its colors, it could be a direct emotional response rather than the product of conscious thought. I'm not sure if that was what you were asking, though.
---------------
Anyway, you've been asking how camouflage developed, so let me try to break it down a little more (as far as I can go, not being an expert). There are two components to the camouflage ability: an instinct/reflex to mimic the environment, and cells that can change color. Each one is useless without the other, right? Well, the cells that change color could have been used previously for communication, so they were already present. The evolutionary development of this would be no different from any other form of communication, like language or birdsong. Communication is useful because it can avoid confrontation, foster cooperation, and attract mates.
Now, the reflex to hide using the color changes can come in much later in time; many generations later. Over the years, the brain of the animal is constantly being tweaked in random ways by the imprecision of the basic genetic process of DNA transcription. Finally, one day, a randomly-developed pathway causes the patterns entering their eyes to be sent down the nerves to the skin cells. Now, if this happened in a human, we would see no effect since our skin cannot change color (except for cofty's example of blushing), so we would never know that our brains were doing this. The pathway might be preserved for generations and do nothing, or it might quickly die out, but we would be ignorant of it either way.
But in this particular animal whose cells already respond colorfully to their emotions, the environmental information causes mimicry by accident. The mimicry might be very crude. Perhaps only color, with no useful pattern, or a pattern that is skewed and not very believable. This is still a big advantage over this animal's pals, so he has a much better chance of surviving. Over the subsequent generations, his descendants develop slightly more and more useful color cells, which have better precision or resolution. Their reflex might be refined to work better, too. These guys are so successful that their relatives that can only change color for communication are quickly replaced, being out-reproduced by their camouflaged cousins.
----------------------
Thus we see the end result today, something that seems very miraculous and intelligently-designed. Does it still seem a bit far-fetched? I think that's natural. Our brains are not good with large numbers, like the number of permutations attempted by evolution every day in our cells. But we do have many other examples in the animal kingdom of complex reflexes, and also of vestigial structures and genes that no longer help us. Evolution is a constantly bubbling cauldron of experiments in tiny gene mutations. Anything that can be tried, no matter how unlikely, will be tried.
The only real requirement to evolve a complex feature is that the feature has to be able to be developed in genetic baby steps. Those steps may not even be useful. For instance, the ability to send environmental information to one's skin cells might develop before the skin cells can change color. This totally useless gene might last many generations simply because there is no real cost to its possessor in terms of energy use, and then, a million years later, bam! The cells of that animal gain the ability to change color, and the pre-existing signal that was being sent now serves a purpose.
The odds might seem astronomical against this, but actually they aren't, because of how many permutations nature is constantly trying out, mostly to little or no good or harm. Once in a while, the process hits the jackpot, but this is to be expected, just like you'd expect someone buying 1,000 lottery tickets a day to eventually win the lottery within his lifetime.