Maybe we need to expand on this a little bit. If ghosts are spirits, and the general consensus is they can pass through walls, materialize and dematerialize, why aren't they seen against a solid background such as a wall? Might not an observer expect to see a ghost pop its head through a wall anywhere? Why are they limited to windows? Since this isn't usually the case, it would seem the window itself must play a part in the appearance of the ghost. So the first things that need to be addressed are the mundane. We need to rule out the obvious before even considering that what is in the picture might really be a ghost at all.
"It's an Example of Pareidolia" - (Whatever That Is....)?
This is the most common explanation skeptics propose, but what is it? It involves how we determine if the object in the picture is a ghost and not simply a shadow or other artifact. To understand that we need to know how the mind interprets such images. To do so we need to understand a term known as pareidolia. The term originates from the Greek, para, meaning in this context, "beside" or "apart from", and eidolon diminutive of eidos, in this context, "image" or "form". Thus the term has come to describe a form that is apart from, and not an actual image. A common example is viewing a cloud and seeing the shape of a horse head, rabbit, or some other recognizable form. Volume 4 has an entire section devoted to pareidolia. You can read more about it there.
One of the characteristics of the mind is it does not like chaos. It attempts to bring order whenever possible. Thus when the randomness in a cloud or other such image is observed, the mind attempts to view it in some recognizable manner. It is believed that one of the earliest purposes of recognition goes back eons into our past. Our ancestors needed to know our friends from our enemies, so we learned to recognize faces. This is why the mind often places eyes, nose, and mouth on any undefined object that might resemble a head. You can prove this for yourself. Simply draw a circle and hand the drawing to someone, telling them to make something out of it. The vast majority will add eyes, nose, and mouth even though they could have just as easily turned it into any number of different things.
One place where pareidolia is used is by psychologists in the Rorschach or Ink Blot test. Here the way a person's mind interprets random patterns is evaluated and a psychological profile is established. While there may be some controversy as to the validity of the test itself, it is clear the test does depend on the same pareidolia effects we encounter in some ghost photographs. The first three cards used in the standard test are reproduced above. What do you see in each? Study carefully and look again with a different mindset. Then ask yourself if you are absolutely certain your ghost picture is really what you first saw in the pattern you photographed.
But Why Does The Ghost Appear In The Window?
Next we need to ask ourselves why there is a pattern at all, doesn't that signify something is there? For those answers consider the composition of the glass itself. Sometimes various impurities such as iron or lead find their way into the glass during manufacture. These may appear under various lighting conditions. If you use a polarizing filter and turn it to different angles you can sometimes observe various coloration and shading when viewing a glass pane. If you take a picture of such a window pane, especially with a flash, this coloration effect can produce a smudged or mottled effect in the picture. Often this effect is seen in older glass where refining techniques were not as efficient as today at removing such impurities.
But it is not limited to old window panes. Today in order to prevent heat transfer various coatings may be intentionally applied to window panes. These are commonly referred to as low emittance or "Low_E glass". Such coatings may appear as a lightly tinted window when simply viewed. But when photographed these window panes may exhibit some rather bizarre patterns depending on the angles and lighting used.
Another contributing factor is how the glass pane itself was made. Early glass was simply rolled and contained imperfections. These can be seen easily if one looks at a straight edge through the window. The edge will appear somewhat wavy due to how these imperfections distort the light traveling through it. Older windows commonly use this type of glass. Newer techniques for making float glass have reduced this tendency so this may not be as important if the window is a newer type, mostly those produced since 1950 or later. But many ghost pictures come from old houses, so this cause must be considered. If these imperfections exist they will concentrate light in some areas and diffuse it in others resulting in the mottled appearance ideal for pareidolia.
What are the environmental conditions at the time? This sounds strange, but consider, if it is winter and the interior of the room is warm and humid, condensation may have formed on the inside of the window. And if it's a warm humid night and the air conditioning is running inside, similar condensation may form on the outside of the window. This is another source of artifacts on the glass.
Finally, if the window is a newer thermal insulated double pane or triple pane type reflections between the panes can be a factor. Depending on the angle, light from a flash can bounce between the panes creating another source of weird lighting conditions. If these result in a pattern it could be interpreted as a ghost. And the most common thermal window problem of all must be ruled out; That being the fogging between the panes. This happens quite frequently if the seals between the panes have been compromised. Consider all of the sightings of Jesus in a patio door glass that make the news from time to time.
But it's not just the window itself that must be considered. More common are reflections in the window. Those may be something completely outside the field of view. The figure shown here demonstrates how this can happen. Note our little photographer taking a picture of the window on the porch of the house on the hill. Next notice his angle with respect to the window. The light from the flash strikes the window (angle of incidence) and is reflected as shown off the window pane (angle of reflection). It leaves at the angle shown, in an upward direction striking the ceiling of the porch, casting the light across it. The light from the porch ceiling returns following the same path. Because of this lighting situation, the porch ceiling is seen by the camera as a reflection from the window itself. A little imagination and we have an instant ghost!
Of course the angles depend on the relative position of the camera and other objects. Even if flash is not used, a tree or some other object at the proper angle will be reflected in the window. There are numerous possibilities depending on each location and what is located where. Some reflections will be apparent and easy to identify, but others may appear vague and ghost-like. Again, throw in a little pareidolia and you have a spirit. Careful attention to objects around the location can help eliminate this possibility. And be aware, the object being reflected could be behind you completely out of sight.
Another form of reflection is also commonly seen. If one takes a flash picture directly at the window, the light reacts as stated above. but since the angle of approach and angle of incidence are perpendicular to the window pane, the flash itself reflects from the window. Due to the intensity of the flash this condition commonly results in lens flare or other such artifacts in the picture. Pictures where the flash or any other light reflects from a window in this manner usually should be disregarded since cameras are unreliable under these types of conditions.
Finally, what is behind the window? Often people take a picture and forget to consider what is in the room behind the window. I have actually seen photographs taken from outside looking into a room where the photographer has captured his fellow investigators on the inside! Since many pictures are taken at night what is behind the window is not illuminated until the flash goes off. You won't see it in the dark so you aren't aware anything is there. Other times a picture on a wall inside may be responsible, or maybe even the drapes on the window. These are things the photographer needs to be aware of. The best way to ensure this is not the case is to keep detailed notes of the conditions under which the picture was taken.