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 or four corner true bilinear warp of an image. |
last modified: March 02, 2020
USAGE: bilinearwarp [-f format] [-v vpmode] [-b bgcolor] "x1,y1 x2,y2 x3,y3 x4,y4" infile outfile
"x1,y1 ... x4,y4" ....... four and only four control point x,y coordinates; PURPOSE: To generate a proper four-point bilinear warp of the input image. DESCRIPTION: BILINEARWARP generate a proper four-point bilinear warp of the input image using the corners of the input image and the specified corresponding coordinates where it is desire that those corner points be located in the output image. The input coordinates are not specified as they will be found from the image dimensions. The four output x,y coordinates must be specified in clockwise order starting with the corresponding point to the upper left corner of the input image. ARGUMENTS: "x1,y1 x2,y2 x3,y3 x4,y4" ... LIST of x,y coordinates in the output image that correspond to where the corners of the input image are desired to be located. The input coordinates are not specified as they will be found from the image dimensions. The four output x,y coordinates must be specified in clockwise order starting with the corresponding point to the upper left corner of the input image. Values may be floats>=0. -f format ... FORMAT for output size. The choices are to make the output the same size as the input (value=I or input) or to make the output the size of the bounding box around the set of specified output control point coordinates (value=B or box). The default is B (bounding box). -v vpmode ... VPMODE is any valid IM virtual-pixel method. The default is black. -b bgcolor... BGCOLOR is the fill color for the background area outside of the warped image when the virtual-pixel method is specified as background. Any valid IM color may be used. Values should be enclosed in quotes if not color names. See http://imagemagick.org/script/color.php Mathematical Background (600KB PDF) NOTE: 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. |
Various Bilinear Warps Of Mandril Image |
|
Original Image |
|
![]() |
|
Arguments: |
Arguments: |
![]() |
![]() |
Arguments: |
Arguments: |
![]() |
![]() |
Comparison Of 1.5 Order Polynomial vs Bilinear vs Perspective Warps |
||
Original Image |
||
![]() |
||
1.5 Order Polynomial Warp |
Bilinear Warp |
Perspective Warp |
![]() |
![]() |
![]() |
The 1.5 order polynomial warp does not preserve straight lines. Thus all the grid lines, the edges of the image and diagonal lines are curved in the quadrilateral. |
The bilinear warp preserves straight lines parallel to the coordinate axes. Thus all the grid lines and the edges of the image remain straight. But the diagonal lines are not preserved and are curved in the quadrilateral. lines curve. |
The perspective warp preserves all straight lines. |
|
Inverse Distance Squared Weighted Warp |
|
![]() |
||
|
Inverse Distance Warp produces strange curvature. |
|
What the script does is as follows:
This is equivalent to the following IM commands for the case
|