Distort or trapezoid transformation
Distort or trapezoid transformation
Hi
I've a problem with Magick++ (c++) where is no distort function implemented.
I
use Ubuntu 16.04 with libmagick++ Q16 12.0.1.
Do you have any solution of this problem?
I'm trying to make left and right oblate image from the stright rectangular image.
Thanks in advance!
Mike
I've a problem with Magick++ (c++) where is no distort function implemented.
I
use Ubuntu 16.04 with libmagick++ Q16 12.0.1.
Do you have any solution of this problem?
I'm trying to make left and right oblate image from the stright rectangular image.
Thanks in advance!
Mike
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Distort or trapezoid transformation
See distort (perspective or bilinear) or affineTransform at http://www.imagemagick.org/Magick++/Ima ... %20Methods. Sorry I do not know Magick++ or any more details.
Re: Distort or trapezoid transformation
Thanks for answers. But they didn't solve my problem.
In ruby language I've been doing trapezoid distortion for example in that way:
points = [1.5, 0,0, 0,squeeze, width,0, width,squeeze, width,height, width,height - squeeze, 0,height, 0,height-squeeze]
img_left = img_left.distort(Magick::PolynomialDistortion, points)
I just want to make it in C++ (with Magick++ library), but apart of that there IS "distort" function in http://www.imagemagick.org/Magick++/Ima ... %20Methods ... there is no such function in real life in library: libMagick++ (libGraphicsMagick++).
In the last case I'll make this function from sources myself, but I don't want to re-invent wheel again - if there is any simple solution. to make "trapezoid distortion".
In ruby language I've been doing trapezoid distortion for example in that way:
points = [1.5, 0,0, 0,squeeze, width,0, width,squeeze, width,height, width,height - squeeze, 0,height, 0,height-squeeze]
img_left = img_left.distort(Magick::PolynomialDistortion, points)
I just want to make it in C++ (with Magick++ library), but apart of that there IS "distort" function in http://www.imagemagick.org/Magick++/Ima ... %20Methods ... there is no such function in real life in library: libMagick++ (libGraphicsMagick++).
In the last case I'll make this function from sources myself, but I don't want to re-invent wheel again - if there is any simple solution. to make "trapezoid distortion".
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Distort or trapezoid transformation
Perhaps perspective distort does what you want. You can give this four coordinates of an image, and the four new coordinates for those points, and the image will be distorted.
See magick-image.c function MagickDistortImage().
See magick-image.c function MagickDistortImage().
snibgo's IM pages: im.snibgo.com
Re: Distort or trapezoid transformation
Could you say something more precise?snibgo wrote:Perhaps perspective distort does what you want.
You can give this four coordinates of an image, and the four new coordinates for those points, and the image will be distorted.
See magick-image.c function MagickDistortImage().
I can't go to C from C++, there is too much job already done in my project to do this.
What I want is this:
https://www.regneregler.dk/g_images/lig ... z-1317.png
not this (not Shear)!
https://mateuxteknisk.systime.dk/filead ... 7b4b6f.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Distort or trapezoid transformation
If you can find the details of distort perspective in Magick++, it will allow you to pick 4 arbitrary points on each image such that you can warp a rectangle into a trapezoid. See http://www.imagemagick.org/Usage/distorts/#perspective
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Distort or trapezoid transformation
With C++, use Image.cpp:
See also http://www.imagemagick.org/script/comma ... hp#distort , the "Perspective" text.
With the PerspectiveDistortion method, give 4 input coordinate as the corners of your image, and output coordinate as the places you want them to move to.void Magick::Image::distort(const DistortImageMethod method_,
const size_t number_arguments_,const double *arguments_,const bool bestfit_)
See also http://www.imagemagick.org/script/comma ... hp#distort , the "Perspective" text.
snibgo's IM pages: im.snibgo.com
Re: Distort or trapezoid transformation
There is no distort function in Magick++ library at all!
I scan all of *.h files, and tried different version of this library.
There are other transform functions, like shear for example or affine transform, but this will not help.
It looks, that I have to make distort function myself.
Such a pity.
![Sad :(](./images/smilies/icon_sad.gif)
I scan all of *.h files, and tried different version of this library.
There are other transform functions, like shear for example or affine transform, but this will not help.
It looks, that I have to make distort function myself.
Such a pity.
![Sad :(](./images/smilies/icon_sad.gif)
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Distort or trapezoid transformation
What version of IM? In 6.9.3-8, "distort" is in Magick++\Image.h
snibgo's IM pages: im.snibgo.com
Re: Distort or trapezoid transformation
Magic++ 8:6.8.9.9-7ubuntu5.3
..
Now I see it. thank you.
..
Now I see it. thank you.
Re: Distort or trapezoid transformation
Thats really odd 'distort' has been available in Magick++\Image.h for ages. It has been added before your version was released in 2014.
-
- Posts: 5
- Joined: 2018-07-06T21:08:17-07:00
- Authentication code: 1152
Re: Distort or trapezoid transformation
How do you know to set "distort:viewport=WxH" for distort function?snibgo wrote: ↑2017-01-06T12:26:57-07:00 With C++, use Image.cpp:With the PerspectiveDistortion method, give 4 input coordinate as the corners of your image, and output coordinate as the places you want them to move to.void Magick::Image::distort(const DistortImageMethod method_,
const size_t number_arguments_,const double *arguments_,const bool bestfit_)
See also http://www.imagemagick.org/script/comma ... hp#distort , the "Perspective" text.