Snibgo's Cylinder Script

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
marcospassos
Posts: 13
Joined: 2014-09-26T08:23:47-07:00
Authentication code: 6789

Snibgo's Cylinder Script

Hi Snibgo!

I've been studying your cylinder script, as well as the Fred's one. I trying to make your script displace for both sides in order to create more realistic images when pitch=0.

Currently, we are able to tilt downward and upward. I would like to reproduce the result of image of the third example:

Do you have any tip or idea?

Best regards,
Marcos

snibgo
Posts: 12436
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Snibgo's Cylinder Script

My scripts assume the camera is infinitely far from the cylinder (parallel projection). For genuine 3-dimensional work, where the camera is close to the object with a wide-angle lens, the maths would be much more difficult and the IM scripts would be far more complex.

I would use POV-Ray. See the examples on that page: http://im.snibgo.com/cylinder.htm.
snibgo's IM pages: im.snibgo.com

snibgo
Posts: 12436
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Snibgo's Cylinder Script

For situations where POV-Ray is not available on the server, and the user does not have full flexibility over camera angle etc (because there are a limited number of photos of mugs), a possible method is:

1. On a laptop or something, write the POV-Ray solution for each mug photograph. This models the mug and camera.

2. Apply these solutions to a 2D gradient image.

3. This gives you absolute displacement maps.

4. Convert these to relative displacement maps.

5. On the server, in live use, software uses IM to apply the relative displacement maps to user-supplied images.

Steps 1-4 could be done on any computer that runs POV-Ray. The server wouldn't need POV-Ray.

This would give you the geometric distortion. You could also use POV-Ray to create lighting and shadow effects, which could be applied on the server to the final output.
snibgo's IM pages: im.snibgo.com

marcospassos
Posts: 13
Joined: 2014-09-26T08:23:47-07:00
Authentication code: 6789

Re: Snibgo's Cylinder Script

I don't have any knowledge about POV-Ray. This script fits well for almost all need I have, except this one.

Do you think that is possible to create a displacement map to displace in both sides symmetrically without using POV-RAY?

snibgo
Posts: 12436
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Snibgo's Cylinder Script

Possible, but "the maths would be much more difficult and the IM scripts would be far more complex."
snibgo's IM pages: im.snibgo.com