Fred's ImageMagick Scripts



    Licensing:

    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.

TINYPLANET


Transforms a spherical panorama to a linear fisheye view.

Download Script

last modified: December 16, 2018



USAGE: tinyplanet [-d dimension] [-b bgcolor] [-r rotate] [-f fade] [-s smooth] [-t threshold] [-n newseed] [-I increment] [-D delay] [-L loop] infile outfile
USAGE: tinyplanet [-h or -help]

-d ... dimension .... square dimension of output; integer>0; default is the height
..................... of the input
-b ... bgcolor ...... bgcolor is the color for the area outside the
..................... circle of the fisheye area; any valid IM color is permitted or
..................... the special name of "stars" to create a black background with
..................... random point star field; use none to make the background
..................... transparent; default=white
-r ... rotate ....... (initial) rotation angle for the output relative to the top of
..................... input being north on the output; floats>=0; default=0
-f ... fade ......... amount of fade in pixels between the image and background color
..................... at the top of the image for viewtype=planet; integer>=0;
..................... default=0
-s ... smooth ....... amount of smoothing for antialiasing when bgcolor=none;
..................... float>=0; default=0
-t ... threshold .... threshold value for controlling the number (density) of random
..................... stars; float>=0; larger values produce less stars; default=99
-n ... newseed ...... random seed for creating the star field when bgcolor=stars
-I ... increment .... angular increment in degrees for generating a rotating animation;
..................... float>0; to avoid irregular rotation, use a value that divides
..................... evenly into 360; default is no animation
-D ... delay ........ delay between frames of the animation; integer>=0; default=20
-L ... loop ......... number of loops of the animation; integer>=0; default=0 means
..................... unlimited looping

PURPOSE: To transform a spherical panorama to a linear fisheye view.

DESCRIPTION: TINYPLANET is designed to transform a spherical (equirectangular) panorama to a linear fisheye view. The spherical (equirectangular) panorama's pixels represent x=longitude and y=latitude. That is, both x and y are angular units. Longitude corresponds to 360 degree range. Thus the left and right sides must wrap contiguously. This means there should be a width to height aspect of 2:1. An normal image can be faked to simulate a spherical panorama by cropping to w/h aspect of 2:1 (width is twice the height), then mirroring it horizontally, appending horizontally, then cropping the center half and rolling it horizontally 50%. The script also allows the output to have any rotation and can be animated in rotation. For animations, be sure to use an output format that supports animation, such as gif.

ARGUMENTS:

-d dimension ... DIMENSION is the square dimension of output image. Values are integers>0. The default is the height of the input.

-b bgcolor ... BGCOLOR is the color for the area outside the circle of the fisheye region. Any valid IM color is permitted or the special name of "stars" to create a black background with random point star field. Use "none" to make the background transparent. The default=white.

-r rotate ... ROTATE is the (initial) rotation angle for the output relative to the top of input being north on the output. Values are floats>=0. The default=0.

-f fade ... FADE is the amount of fade in pixels between the top of the input image and background color for viewtype=planet. This is a preprocessing step so that the outside of the fisheye circular region will fade to the background color. Values are integers>=0. The default=0.

-s smooth ... SMOOTH is the amount of smoothing for antialiasing when bgcolor=none or stars. Values are float>=0. The default=0.

-t threshold ... THRESHOLD value for controlling the number (density) of random stars. Values are floats>=0. Larger values produce less stars. The default=99. Nominal values are 99 to about 99.9.

-n newseed .. .NEWSEED is the random seed for creating the star field when bgcolor=stars. Values are integers>=0. The default is totally random star placement from run-to-run.

-i increment ... INCREMENT is the angular increment in degrees for generating a rotating animation. Values are floats>0. To avoid irregular rotation, use a value that divides evenly into 360 (e.g. 2,5,10,15,20,30,45). The default is no animation.

-d delay ... DELAY between frames of the animation. Values are integers>=0. The default=20. It is not recommended to use 0.

NOTE: For animations, be sure to use an output format that supports animation, such as gif.

REFERENCES:
http://www.photographymad.com/pages/view/little-planet-photos-5-simple-steps-to-making-panorama-worlds

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.


EXAMPLES


Example 1 - Variation Background -- Single Image

Original Image
(source)

Arguments:
-b white
(default)
Arguments:
-b "#B4F2FE" -f 100
Arguments:
-b stars
Arguments:
-b white -r 45


Example 2 - Variation Background -- Small Animation

Original Image
(source)

Arguments:
-b white -d 400 -I 5 -D 20 -L 0
Arguments:
-b "#B4F2FE" -f 100 -d 400 -I 5 -D 20 -L 0
Arguments:
-b stars -d 400 -I 5 -D 20 -L 0


What the script does is as follows:

  • Starts with a spherical panorama (equirectangular) image
  • Transforms it to linear panorama using -distort polar

This is equivalent to the following IM commands for the case of a simple color background.

  • convert "$infile" -rotate 180 \
    -virtual-pixel HorizontalTile -background $bcolor \
    +distort Polar 0 +repage -rotate 180 \
    "$outfile"