cylindrical distortion

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Post Reply
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

cylindrical distortion

Post 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 http://www.imagemagick.org/Usage/distor ... 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 :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: cylindrical distortion

Post by anthony »

See Fred Wienhaus's Script Cylinderize. This has been discussed, but has not been implemented in -distort.
http://www.fmwconcepts.com/imagemagick/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: cylindrical distortion

Post by javismiles »

thank you very much Anthony,
im looking at the script on http://www.fmwconcepts.com/imagemagick/ ... /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 :)
Jav
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: cylindrical distortion

Post 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

<?php
// Run the script
exec("/FULL PATH TO AUTOTRIM/autotrim.sh 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: cylindrical distortion

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: cylindrical distortion

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: cylindrical distortion

Post by anthony »

In other words an orthogonal view of a cylinder with an image wrapped around it. :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply