Ask Your Question
1

warpPerspective gives unexpected result

asked 2013-04-19 19:22:06 -0600

Papercut gravatar image

updated 2013-04-21 04:33:51 -0600

Andrey Pavlenko gravatar image

Hi guys,

I am implementing "Quad Warping" in order to do fat/skinny face effect. Quad Warping is quite much work but I don't know if there is any other options to do the face effect things.

Anyways, I sort of completed writing code but the result image seems not right and I wonder if it is a bug in OpenCV. Please see the image below:

image description

Can you guys notice the pixels have been rotated up even though size of resulting rectangle is right? Is this a bug? or a right attribute of WarpPerspective() ?

edit retag flag offensive close merge delete

Comments

Just a note: please give a more informative title, thank you.

Guanta gravatar imageGuanta ( 2013-04-20 05:23:17 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-04-22 12:03:50 -0600

Papercut gravatar image

image description

Okay. I got it by myself. WarpPerspective() doesn't actually give us a right result when we want all contents in the image staying in a same relative position. WarpAffine is the answer. Only thing I think it's annoying is that it only transforms triangles.

edit flag offensive delete link more
0

answered 2013-04-20 14:22:31 -0600

It is not clear how Quad Warping relates to projective transformation. The "bug" in WarpPerspective is not visible in the images you provided. You should give more details about what exactly you were doing.

edit flag offensive delete link more

Comments

Dude. I attached 6 photos. Look at the upper right photo. Can't you see the four parts of the photo are discontinuous? And can't you imagine what the correct one should look like? Do you need more explanation on this?

Assuming a transformation is made from (0,0)(10,0)(0,10)(10,10) to (0,0)(10,0)(0,10)(15,10) on the image. Because only the bottom right point moves right, the pixels in the original image should stretch towards right. The more stretch in the lower part. They must not stretch to neither left, down nor up. Tell me if you need more explanation here. However, in the transformed image which WarpPerspective() resulted looks like the 6th photo in the attached. Please find the red horizontal grid I drew. The pixels in the original image actually shifted towards up!

Papercut gravatar imagePapercut ( 2013-04-21 22:04:13 -0600 )edit

Question Tools

Stats

Asked: 2013-04-19 19:22:06 -0600

Seen: 1,190 times

Last updated: Apr 22 '13