Fred's ImageMagick Scripts
|
Corrects for fisheye distortion in an image. |
last modified: May 30, 2008
|
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: FISHEYE is designed to transform a fisheye image into a normal perspective view. 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<360. 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<ifov<180. A value of 53 degrees corresponds to a "normal" view from a 35 mm camera. The default is 120 degrees. The value for ofov relative to the ifov determines the proportional amount of the fisheye area that will be transformed. 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 not viewed perfectly horizontal, i.e. the camera was tilted up or down from horizontal, 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 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
|