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. |
Applies either a rectangular (cartesian) to log-polar transformation or a log-polar to rectangular (cartesian) transformation on an image. |
last modified: July 31, 2021
USAGE: logpolar [-m mode] [-c xc,yc] [-r rmn,rmx] [-a amn,amx] [-v vpmode] [-b bgcolor] [-i interpolate] infile outfile
-m .... mode ......... rect2logpolar or logpolar2rect; default=rect2logpolar PURPOSE: To apply either a rectangular (Cartesian) to log-polar transformation or a log-polar to rectangular (Cartesian) transformation on an image. DESCRIPTION: LOGPOLAR applies either a rectangular (Cartesian) to log-polar transformation or a log-polar to rectangular (Cartesian) transformation on an image. The user has control of the range of radius, angle and center in the transformation. ARGUMENTS: -m mode ... MODE is the transformation mode, which can be either rect2logpolar (rectangular to log-polar) or logpolar2rect (log-polar to rectangular). The former, rect2logpolar, treats the input as a normal rectangular image with columns representing X and rows representing Y and treats the output as having columns representing angle and rows representing the log of radius. The latter, logpolar2rect, treats the input as having columns representing angle and rows representing the log of radius and treats the output as having columns representing X and rows representing Y. Note that in a polar image, nominally the left column is angle=amn=-180, the middle column is angle=0 and the right column is angle=amx=180. Similarly, the top row corresponds to the radius=rmin and the bottom row corresponds to radius=rmx. -c xc,yc ... XC,YC are the pixel coordinates for the transformation center. The default is the image center. -r rmn,rmx ... RMN,RMX are the min and max radii. By default, rmn=0 and rmx=(half image diagonal). This provides a transformation that includes the whole image. However, for the rect2polar mode, this will cause the output image to contain areas that are outside the input image. They will be filled as determined by the virtual pixel setting. Value are non-negative floats. Values are generally non-negative floats, but four other choices are allowed: w, h, d and m, where w=width/2, h=height/2, d=diagonal/2 and m=min(width,height)/2. -a amn,amx ... AMN,AMX are the min and max angles. By default, amn=-180 and amx=180. Values for amn and amx are floats between -180 and 180. -v vpmode ... VPMODE is the virtual-pixel mode. Any valid IM virtual-pixel setting is allowed. The default is black. -b bgcolor ... BGCOLOR is the background color to use with vpmode=background. Any valid IM color may be used. The default is black. -i interpolate ... INTERPOLATE is the type of interpolation to use. The choices are: nearest (n), bilinear (b), catrom (c), average4 and average9. The default=bilinear. Note that catrom is the same as Key's cubic convolution. Note that this script may be slow due to the use of -fx. 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. |
Original Image |
![]() |
Image In Log-Polar Coordinates Using This Script |
![]() |
Image In Polar Coordinates Using Polar Script |
![]() |
What the script does is as follows:
This is equivalent to the following IM commands for the case
|