Skip to content

formula for distort function #540

Answered by emcconville
michaelba8 asked this question in Q&A
Discussion options

You must be logged in to vote

The beauty of open source is that there's nothing stopping you from reading the source code. For distort formulas, check out distort.c in ImageMagick. The authors left plenty of math formulas as comments to help guide future readers.

Here's an example of a comment for PerspectiveDistortion

 /*
 Perspective Distortion (a ratio of affine distortions)
        p(x,y)    c0*x + c1*y + c2
    u = ------ = ------------------
        r(x,y)    c6*x + c7*y + 1
        q(x,y)    c3*x + c4*y + c5
    v = ------ = ------------------
        r(x,y)    c6*x + c7*y + 1
   c8 = Sign of 'r', or the denominator affine, for the actual image.
        This determines what part of the distorted image is 'ground'

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@michaelba8
Comment options

@emcconville
Comment options

Answer selected by michaelba8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants