There is a related question on this site here: Why glass is transparent? Which explains that glass is transparent because the atoms in glass have very large energy differences between energy levels and photons of visible light do not have enough energy to excite electrons from one energy level to another. Whereas, electrons in atoms of most other substances can be excited so the photon is absorbed. But my question is, why don't these excited electrons return to their original energy level and release a photon in the direction the original photon was travelling, hence allowing the light to pass through the object? Edit: I had not realised earlier that this exact same question had been asked before on this site here: Why aren't all objects transparent? So, I shall clarify my question a bit more. The answers to the linked question say that the energy of the excited electron is lost so the light is re emitted as waves with longer wavelengths which we cannot see. I'd like to know how exactly the electron loses this energy. One answer to the linked question states that the energy is lost to lattice vibrations, but I'd like to know how exactly an excited electron still bound to the atom can transfer its energy to lattice vibrations.
When an atom or molecule absorbs a photon, it enters an excited state; each excited state has a mean lifetime.
When the atom or molecule returns to the ground state it may emit a phonon (vibrations), or it may decay through multiple levels; in this case there are multiple photons, with different wavelengths.
In the case where the absorbed and emitted photons have the same wavelength, the new photon is emitted at a random time and random direction.
So there are four things going on that break up the image: loss of photons which are transformed into vibrations (heat), or which change color (wavelength) or become invisible (infrared), delays in timing which breaks up the coherence of the image (similar to a wavy mirror or water), and random directions.
The last, the random directions, rapidly destroys the intensity of the transmitted image, generating a random background.
For those curious as how a transparent medium transmits an image, and why light slows down inside (but resumes speed when it leaves), I've repeated my previous answer to this question:
Transparent materials (glass, air) transmit images; if the image is distorted or indistinct, we know that the material is altering the coherence of the optical information. That is, what started out at the beginning has not arrived all at the same time. With enough distortion the image is completely lost.
So what is required for a transparent medium to successfully transmit an image? Since light is a physical wave, the transparent medium must preserve the coherence of the phase information of the light. In a typical glass the phase front is slightly slowed while traveling through the glass; this slowing is encoded in the index of refraction, $n = c/v$.
If the material absorbs some frequencies, the material will appear to be colored; a photon that is absorbed (depending on the energy level structure) can be re-emitted, but this will be at (a) a random time later, and (b) in a random direction. No image for this color! There is an exception: stimulated emission, which is the key to building a laser. But this is not how images are transmitted in a passive material.
The process that transmits images can be summed up as Coherent Forward Scattering: Coherent, because otherwise the image integrity is reduced; Forward, because the image is transmitted in this direction, through the material; and Scattering, the remaining available generalized mechanism at the quantum level.
The result is quite like the Huyghen's wavelet model for light transmission: the photons are the waves that are scattered coherently, and because it is coherent, they are able to interfere both constructively and destructively to maintain the coherence of the overall phase front.
It is the interference that slows the phase velocity through through the material; the individual photons continue to "move" at the speed of light, $c$, but the effective motion of the phase front is slowed.
Richard Feynman devotes some time to this in his lectures on QED: The Strange Theory of Light and Matter