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. |
Corrects for fisheye distortion in an image. |
last modified: January 17, 2022
USAGE: defisheye [-i ifov] [-o ofov] [-t type] [-f format] [-c xc,yc] [-r radius] [-a angle] infile outfile
-i .... ifov ......... input (fisheye) image field of view in degrees; PURPOSE: To correct for fisheye distortion in an image. DESCRIPTION: DEFISHEYE is designed to transform a fisheye image into a normal perspective view looking towards the center of the fisheye image. ARGUMENTS: -i ifov ... IFOV is the input fisheye image field of view in degrees. A value of 180 will correspond to a hemispherical fisheye image within the circular area. Values are floats in the range 0<ifov<=180. The default is 180 degrees for a full hemisphere. -o ofov ... OFOV is the output perspective image field of view in degrees. Values are floats in the range 0<ofov<180. The default is to use 120 degrees both vertically and horizontally for a circular fisheye and diagonally for a full frame fisheye. The value for ofov relative to the ifov determines the proportional amount of the fisheye area that will be transformed. Note that in comparison, a value of 48.8 degrees corresponds to a diagonal field of view from a 35 mm camera (film size 36mm x 24mm) with a 50mm focal length lens, i.e. a "normal" view. Similarly, when the image diagonal is equal to the focal length of the camera, the field of view is about 53.1 degrees. Although the default value is perhaps not appropriate to a normal perspective image, this will produce an image that maximizes the area covered, but without too much distortion. If the original fisheye image was viewed obliquely, i.e. the camera was tilted between horizontal and vertical, then the resulting perspective view will have perspective distortion. That is vertical edges will be tilted outward or inward. Post processing with my 3Drotate or rotate3D script will then correct for this perspective distortion. Perspective distortion will be more pronounced with larger values for ofov. -t type ... TYPE is the type of fisheye lens. The choices are: linear (equidistant), equalarea (equisolid), orthographic and stereographic. The default is linear. -f format ... FORMAT is the format of the fisheye lens image. The choices are: circular (image fills a circle that spans the minimum of the width or height) or fullframe (image spans a circle that spans the diagonal dimension). The default is circular. -c xc,yc ... XC,YC are the pixel coordinates in the input fisheye image that correspond to the (circular fisheye area) center. The pixel at this coordinate will then become the center of the perspective image. The default values are the center of the input fisheye image. Values are non-negative floats. You can use the -d option to validate your choice of center and radius for the fisheye image. See more below. -r radius ... RADIUS is the radius of the fisheye circular area in the input image. Values are floats greater than zero. The default is half the minimum value between the input image width and height. -a angle ... ANGLE is the clockwise positive rotation angle for the output perspective image relative to the orientation of the input fisheye image. Values are non-negative floats in range 0<=angle<360. The default is 0. -d ... Use of this argument produces an ouput image that is simply the input image with a circle drawn on it to show where the expected fisheye image area is located. You can specify a radius and center point if you want to adjust the transformation to use the precise center and radius that matches the area delimited by the circle. Radius and center default as described above. -s scolor ... SCOLOR is the stroke color to use to draw the circle when the -d argument is used. The default is white.
See the following references for definitions and mathematical details of each
type of fisheye lens: NOTE: This script uses -fx and therefore will be rather slow. 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. |
Mandril (Square) Image - Artificially Created Fisheye Types / Circular |
||||
Fisheye Distorted Images |
Linear |
Equal Area |
Orthographic |
Stereographic |
![]() original |
![]() |
![]() |
![]() |
![]() |
Corrected Images |
Linear |
Equal Area |
Orthographic |
Stereographic |
![]() original |
![]() |
![]() |
![]() |
![]() |
Woman (Non-Square Image) - Artificially Created Lineaer Fisheye - Circular vs. Fullframe |
||
Fisheye Distorted Images |
Linear Circular |
Linear Full Frame |
![]() original |
![]() |
![]() |
Corrected Images |
Linear Circular |
Linear Full Frame |
![]() original |
![]() |
![]() |
Computer Generated Linear Circular Fisheye Image - Correct vs Incorrect Type |
||||
Original |
Linear |
Equal Area |
Orthographic |
Stereographic |
![]() |
![]() |
![]() |
![]() |
![]() |
Computer Generated Linear Circular Fisheye Image (Full Size) |
|||
Original |
Linear |
||
![]() |
![]() |
Linear Full Frame Fisheye Image |
|||
Original |
![]() |
||
Corrected |
![]() |
||
Trimmed |
![]() |
Equisolid Full Frame Fisheye Image |
|||
Original |
![]() |
||
Corrected |
![]() |
||
Perspective Corrected |
![]() |
Linear Circular Fisheye Image - Adjustments |
|||
Original |
![]() |
||
Original With |
![]() |
||
Original With |
![]() |
||
Under Corrected |
![]() |
||
Over Corrected |
![]() |
||
Good Correction |
![]() |
What the script does is as follows:
This is equivalent to the following IM commands for the case of a
|