Page 1 of 1

cylindrical distortion

Posted: 2011-06-17T22:46:35-07:00
by javismiles
hi and good day :) quick question,
what is the most efficient way to do a cylindrical distortion? so i have a flat picture and i want to project it in perspective
on a cylinder? the operation should combine the cylindrical distortion with perspective at the same time,
i know how to do the perspective one with +distort, so the question is how to combine that with a cylindrical distortion at the same time?
im reading through ... r_distorts
but not sure really what to do, i see the barrel distortion for example, or the shepard, but not sure which one to use to get the same perspective distortion
ive been making but cylindrical at the same time
thank u for any help ;)
Jav :)

Re: cylindrical distortion

Posted: 2011-06-17T23:54:21-07:00
by anthony
See Fred Wienhaus's Script Cylinderize. This has been discussed, but has not been implemented in -distort.

Re: cylindrical distortion

Posted: 2011-06-18T00:21:07-07:00
by javismiles
thank you very much Anthony,
im looking at the script on ... /index.php,
i downloaded it also, what type of file is it? im tring to read it but i cant manage ,what type of script is it, how can i run it?
is there any way to use this through php?
hopefully this will be integrated with -distort in future :)

thanks very much again :)

Re: cylindrical distortion

Posted: 2011-06-18T01:19:21-07:00
by Bonzo
1.Download the script and upload it to your server.
2.Change the permissions to 755 on the script
3.Write your php code like this using the full path to the script

Code: Select all

// Run the script
exec("/FULL PATH TO AUTOTRIM/ zelda3_border2w.png fred.png 2>&1", $array); 
//Display any errors
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
Note I add .sh to the filename so I can easily see it is a shell script but it should work without it.

Re: cylindrical distortion

Posted: 2011-06-18T05:19:40-07:00
by anthony
The script is a bash shell script which generally, run under UNIX-like environment, such as Linux, MacOSX or Cygwin.

The previous answer assumes the PHP is running in a UNIX-like environment.

[quote="javismiles"hopefully this will be integrated with -distort in future :)[/quote]
I hope so too. But I have only so much time I can devote to IM.

As a FYI to others reading this...
Distorts need a specific set of code to be implemented. Most are optional though generally preferred if posible.
  • Convert a input argument list and image, to a set coefficients. Both are currently just a list of floats, but output may be a structure more specific to the distortion.
  • OPTIONAL: figure out the 'bestfit' viewport for the input image involved, may make slight modification
  • OPTIONAL: Print out of a FX equivalent to the next step, (output with -verbose setting)
  • convert a destination coordinate (distort space) to source image coordinator, (regardless of hit or miss),
    also the pixel is invalid (no possible hit of the source plane), or optionally if close to the horizon (edge of invalidity), its 'transparency'
  • OPTIONAL: Scaling vectors for area lookup. These can consist of either two unit orthogonal vectors on destination image, mapped to vectors on source image. OR the deritive functions of the distortion mapping functions. Often this is the hardest bits of mathematics to work out, but results in very well defined distored images, especially when images become highly compressed in various areas.

Re: cylindrical distortion

Posted: 2011-06-18T10:19:32-07:00
by fmw42
My cylinderize script is an approximation of the perspective on a cylinder. It is not exact. It wraps the picture about a perfectly vertical cylinder and then distorts the top and bottom to "appear" as if in perspective. but it is not a perspective as the cylinder sides always remain parallel.

Instructions for using my scripts in PHP can be found on my hope page at the link below.

Re: cylindrical distortion

Posted: 2011-06-19T04:53:15-07:00
by anthony
In other words an orthogonal view of a cylinder with an image wrapped around it. :-)