Hello All,
I am doing a program in VC++ using ImageMagick.
I have a 2D image and I want to do Perspective rotation about Y-axis.
Can any one please explain how to do perspective rotation about Y-Axis with 2D image.
Can I do this task with ImageMagick lib.
Thanks in advance
wizards
Perspective transformations
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Perspective transformations
IM currently uses either control points or a transformation matrix. You would need to compute either the transformation matrix or the relevant control points. see http://www.imagemagick.org/Usage/distorts/#perspective
I have done this in my script, 3Drotate, but it is quite mathematically involved. But is explained in the linked Mathematical Description PDF.
See my web site below.
I have done this in my script, 3Drotate, but it is quite mathematically involved. But is explained in the linked Mathematical Description PDF.
See my web site below.
Re: Perspective transformations
Hello Thank you very much for your information.
I am using VC++ as a programming language. Please may i know the lib calls to get that effect.
Thanks in advance
wizards
I am using VC++ as a programming language. Please may i know the lib calls to get that effect.
Thanks in advance
wizards
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Perspective transformations
sorry I do not know VC++ or any other API
Re: Perspective transformations
Hello,
I gone through the 3DRotate example and the "Mathematics Background.pdf". I am very much thankfull to u to gave a such nice explenatation.
I implemented an algrothm in VC++ with angle=-35,pef=1, sx=1.005,sy=1.005, du=0,dv=0, Idx=0, Idy=0 for Pan effect.
Now the image is rotating about the z-axis.
But i don't want to rotate the image about the z-axis instead the image should be streatched. That is the streatching will be small at center of the image and more at the edges.
As you know this will give a 3D effect, that is the the objects closer to fov will be big and the objects far away from the fov will appear small.
Can you please give any information what should i change for the "Mathematics Background.pdf" to get 3D effect.
Thanks in advance.
I gone through the 3DRotate example and the "Mathematics Background.pdf". I am very much thankfull to u to gave a such nice explenatation.
I implemented an algrothm in VC++ with angle=-35,pef=1, sx=1.005,sy=1.005, du=0,dv=0, Idx=0, Idy=0 for Pan effect.
Now the image is rotating about the z-axis.
But i don't want to rotate the image about the z-axis instead the image should be streatched. That is the streatching will be small at center of the image and more at the edges.
As you know this will give a 3D effect, that is the the objects closer to fov will be big and the objects far away from the fov will appear small.
Can you please give any information what should i change for the "Mathematics Background.pdf" to get 3D effect.
Thanks in advance.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Perspective transformations
You are apparently not using the right rotation matrix.
Sorry, looks like I made a mistake in typing the following in the PDF docs:
pan = right hand positive rotation about Z axis <--- should be Y axis
tilt = right hand negative rotation about X axis
roll = right hand positive rotation about Y axis <--- should be Z axis
But the matrices are correct.
Use Pan rotation:
Rp0 = (cospan 0 sinpan)
Rp1 = (0 1 0)
Rp2 = (-sinpan 0 cospan)
Let me know if that fixes your problem.
I will fix the PDF file.
Sorry, looks like I made a mistake in typing the following in the PDF docs:
pan = right hand positive rotation about Z axis <--- should be Y axis
tilt = right hand negative rotation about X axis
roll = right hand positive rotation about Y axis <--- should be Z axis
But the matrices are correct.
Use Pan rotation:
Rp0 = (cospan 0 sinpan)
Rp1 = (0 1 0)
Rp2 = (-sinpan 0 cospan)
Let me know if that fixes your problem.
I will fix the PDF file.
Re: Perspective transformations
Hello,
I used the pan matrix and i got the rotation about y-axis correctly.
My aim is to use perspective rotation is to get a 3D effect.
Now with this algorithm if the image is rotated 35 degrees then some part of the image is looks into the monitor about 35 degrees(popin) and some part of the image is comes out the monitor (popup) about 35 degrees and the rest of the image in left side and right side is black.
I dont want to rotate image in and out of the monitor, instead the image should be streatched to left and right about its center.
That is the stretching to the left is minimal at center and more when goes towards the left of the image also the streatching to the right of the image will be minimal at center and more when goes towards the ritht.
Can you please give an idea what modifications should i do to the "Mathematics Background.pdf" document.
Thanks in advance.
I used the pan matrix and i got the rotation about y-axis correctly.
My aim is to use perspective rotation is to get a 3D effect.
Now with this algorithm if the image is rotated 35 degrees then some part of the image is looks into the monitor about 35 degrees(popin) and some part of the image is comes out the monitor (popup) about 35 degrees and the rest of the image in left side and right side is black.
I dont want to rotate image in and out of the monitor, instead the image should be streatched to left and right about its center.
That is the stretching to the left is minimal at center and more when goes towards the left of the image also the streatching to the right of the image will be minimal at center and more when goes towards the ritht.
Can you please give an idea what modifications should i do to the "Mathematics Background.pdf" document.
Thanks in advance.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Perspective transformations
Sorry I don't understand this. 3Drotate, rotates about the middle of the image, so you get the effect you described.I dont want to rotate image in and out of the monitor, instead the image should be streatched to left and right about its center.
That is the stretching to the left is minimal at center and more when goes towards the left of the image also the streatching to the right of the image will be minimal at center and more when goes towards the ritht.
Perhaps you want more of an effect like in my script, 3Dreflect. Look at the examples there and let me know if that is what you desire. 3Dreflect rotates about the left side of the image rather than the center.
Otherwise, please explain better.
The other way to make perspective is just to use 4 control point pairs as per the examples described at http://www.imagemagick.org/Usage/distorts/#perspective
Re: Perspective transformations
Hello,
I should say very much thanks to you to have very much interest in this topic.
I am planing to create a 3D anaglyph image for a give 2D image.
For this I will consider give 2D image as left eye view and now I have to create right eye view.
I came to know that the perspective rotation, perspecive skew, perspective distortation etc,. will create ritht eye view.
I generated an output image as described in PDF and this image is not suitable for right eye view to create anaglyph.
Suppose in an image if some objectas are very much closer to the camera and some are very far to the camera then the image shoue be
original - ------ result
| | /-------/
| | / /
| | / /==Center point (That is from the center, the upper part should rotate/skew towards right and lower part should rotate towards left)
| | /-------/
------
And suppose in an image if some of the objects are some what away from the camera and some are very far
then the transformation should be
original - ------ result
| | /-------/
| | / /
| | | |==Center point (Only the upper part will rotate/skew towards right)
| | |-------|
------
Can I do 4 point perspective transformation for this. If so what modifications can i do for the PDF?
Can I find any transfromation matrix T in the eqations (u,v,1) = A-1 M T B (i,j,1).
Thanks in advance
I should say very much thanks to you to have very much interest in this topic.
I am planing to create a 3D anaglyph image for a give 2D image.
For this I will consider give 2D image as left eye view and now I have to create right eye view.
I came to know that the perspective rotation, perspecive skew, perspective distortation etc,. will create ritht eye view.
I generated an output image as described in PDF and this image is not suitable for right eye view to create anaglyph.
Suppose in an image if some objectas are very much closer to the camera and some are very far to the camera then the image shoue be
original - ------ result
| | /-------/
| | / /
| | / /==Center point (That is from the center, the upper part should rotate/skew towards right and lower part should rotate towards left)
| | /-------/
------
And suppose in an image if some of the objects are some what away from the camera and some are very far
then the transformation should be
original - ------ result
| | /-------/
| | / /
| | | |==Center point (Only the upper part will rotate/skew towards right)
| | |-------|
------
Can I do 4 point perspective transformation for this. If so what modifications can i do for the PDF?
Can I find any transfromation matrix T in the eqations (u,v,1) = A-1 M T B (i,j,1).
Thanks in advance
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Perspective transformations
Stereo is a perspective change, but not a rotation, but a translation of the camera location. However, you need depth information (depth image) to effect this. So a 2D image is not going to work for this. I know of no way to generate a stereo pair from a 2D image that works well by using perspective transformation. But I am not an expert on stereo. Search Google for generating stereo pair from one image