Quantcast
Viewing all articles
Browse latest Browse all 35

MagickWand • unexpected PerspectiveDistortion result

I am using MagickDistortImage trying to correct a trapezoid distortion like this:

Image may be NSFW.
Clik here to view.
Image


(image hand painted, just for demonstration purposes)
The image has 640x480 pixels.

I'm using the following parameters:

CODE:

MagickDistortImage(TheWand, PerspectiveDistortion,  [(0.5, 17.5), (0.5, 9.5), (640.5, 29.5), (639.5, 9.5), (640.5, 413.5), (639.5, 444.5), (0.5, 432.5), (0.5, 444.5)],  8, MagickFalse);
(round brackets inserted just for grouping the coordinates to improve readabilty, it is simply a flat array of double with 16 entries (8 coordinate pairs))

The source coordinates specify the red lines on the next picture, the destination coordinates the blue lines. Both use the full width of the image but only part of the height. So source is a trapezoid and destination is a rectangle.

Image may be NSFW.
Clik here to view.
Image


The result is this:
Image may be NSFW.
Clik here to view.
Image


At first glance, it looks fine, but if you look closer, you will see that not just "horizontal" lines have been corrected but also the vertical lines have been moved.

I didn't expect that. Am I doing anything wrong?

Statistics: Posted by dummzeuch — 2019-12-10T06:57:57-07:00



Viewing all articles
Browse latest Browse all 35

Trending Articles