I'd like to overlay a glass jar onto an image with realistic light bending. Can anyone think of a way to automate this effect (perhaps this can be done with the raytracing package rayica)?


|
I'd like to overlay a glass jar onto an image with realistic light bending. Can anyone think of a way to automate this effect (perhaps this can be done with the raytracing package rayica)?
|
|||||||||||
|
|
================= UPDATE ====================== Due to @halirutan comment I'll add a note on realism. First of all pure water and clouds are not the best subject to simulate reflecations because they have fractal structure - meaning they tend to appear the same on different magnification scales. So it is hard to give impression to a human eye of refraction effect. I suggest introducing some non-fractal elements, like the one below. Also @halirutan is right slight offset of horizon line from vertical my enhance effect perception. This is the new app with vertical and horizontal scales added. Code is below the app. (I do not give URL for o variable - please find your own source.)
I also realized we can do magnifying or metaphorical effects like the one below:
================= ORIGINAL POST ====================== Some public ocean image and your jar:
Now this line does:
Here you go:
This creates mask:
Blur original image and use mask to cut a hole. Then use mask to create filler for the hole:
Finally fill the hole with
Your given glass jar image has slight shadow against white background which is a usual thing that Photoshop artists add. A photo without the shadow would blend with ocean background better. There is also another |
|||||||||||
|
|
This is more of an add-on to Vitaliy's excellent answer, than a completely new approach. I wanted to try to simulate some of the image distortion that would be seen at the jar walls. A simple (though utterly wrong in a physics sense) way to do this is to make the demagnification vary according to the jar image intensity. Load a picture and the jar image, and pad the jar image to match the picture size.
For the fake refraction, I use a grayscale copy of the jar with a gamma adjustment (this amplifies the effect).
To combine the refraction effect with the original image I use Vitaliy's
|
|||||||
|
|