Copyright © Fred Weinhaus My scripts are available free of charge for non-commercial (non-profit) use, ONLY. For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net. If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment. Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php Please read the Pointers For Use on my home page to properly install and customize my scripts. |
Generates a perspective (rectilinear) image from a region of a spherical panorama image. |
last modified: December 15, 2018
USAGE: sphericalpano2rect [-c coords] [-u units] [-f fov] [-m maxsize] [-b bgcolor] infile outfile USAGE: sphericalpano2rect [-h or -help]
-c ... coords .......... coordinates in the panorama image (cx,cy) to be used as the PURPOSE: To generate a perspective (rectilinear) image from a region of a spherical panorama image. DESCRIPTION: SPHERICALPANO2RECT generates a perspective (rectilinear) image from a region of a spherical panorama image. The region is identified by a point on the panorama image in pixels or degrees and the specified output field of view. ARGUMENTS: -c coords ... COORDS is the coordinates in the panorama image (cx,cy) to be used as the center of the output image (the look point). Values are floats>=0. The default=center of panorama. Two comma separated values are required, if provided. -u units ... UNITS for specifying the look coordinates. Choices are degrees (d) or pixels (p). VAlues are floats>=0. The default=pixels. -f fov ... FOV are the fields of view of the output image (xfov,yfov) in degrees. Values are 0<floats<180. The default="60,60". If only one value is supplied, it will be use for both dimensions. Smaller values zoom in (telephoto lens) and larger values zoom out (wide angle lens). For 35 mm film, a 50 mm focal length lens will have a diagonal field of view of about 47 degrees. Values larger than about 120 degrees for the field of view will show distortions. -m maxsize ... MAXSIZE is the maximum size of the output image in pixels corresponding to the the larger field of view dimension. Values are integers>0. The default=512. -b bgcolor ... BGCOLOR is the background color for virtual-pixels. Any valid IM color is allowed. The default=black. -i interpolation ... INTEPOLATION method. Any valid IM interpolation method is allowed. The default=bilinear. NOTE: This script will be slow due to the use of -fx. On my dual core INTEL Mac mini with 2.8 GHz processor and OSX Sierra, it takes about 10 sec to create a 512x512 perspective output starting from a 2000x1000 pixel spherical panorama. Processing time increases/decreases approximately with the square of the output dimension.
REFERENCES: CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. |
Example 1 -- Different Locations |
Original Image |
(Click For Full Sized Image)
![]() |
Arguments: -c 180,90 -u degrees -f 60 -m 512 (defaults) (center) |
![]() |
Arguments: -c 0,90 -u degrees -f 60 -m 512 or -c 360,90 -u degrees -f 60 -m 512 (vertical center; span left and right sides) |
![]() |
Arguments: -c 180,30 -u degrees -f 60 -m 512 (top center) |
![]() |
Arguments: -c 180,150 -u degrees -f 60 -m 512 (bottom center) |
![]() |
Arguments: -c 780,520 -u pixels -f 60 -m 512 |
![]() |
Arguments: -c 1730x500 -u pixels -f 60 -m 512 |
![]() |
Example 2 -- Different Fields Of View |
Original Image |
(Click For Full Sized Image)
![]() |
Arguments: -c 780,520 -u pixels -f 60,60 -m 512 |
![]() |
Arguments: -c 780,520 -u pixels -f 120,60 -m 1024 |
![]() |
Arguments: -c 780,520 -u pixels -f 60,120 -m 1024 |
![]() |
Arguments: -c 780,520 -u pixels -f 120,120 -m 1024 |
![]() |
Arguments: -c 780,520 -u pixels -f 150,150 -m 1024 |
![]() |
Arguments: -c 780,520 -u pixels -f 170,170 -m 1024 |
![]() |
Example 3 -- Animation |
Original Image |
(Click For Full Sized Image)
![]() |
Arguments: phi=90 degrees theta from 0 to 350 in 10 degree increments |
![]() |
What the script does is as follows:
See the script for mathematical and code details. |