Pages: [1]   Go Down

Author Topic: Is perspective correction in PS so painful?  (Read 7070 times)

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Is perspective correction in PS so painful?
« on: February 10, 2008, 06:44:17 am »

Yesterday I did a try to correct perspective with PS. I shot my wide angle in a quite tricky way (not only pitched to the subject but also rotated) so that I could check how easy is to use PS for perspective correction in extreme cases.

My goal was to achieve with a pitched extreme wide angle exactly the same perspective we would have achieved with a tilt-shift lens shifted keeping the direction of observation perpendicular to the plane the object is contained, just to find out if shifted lenses can be properly substituted by wide angle+software correction (leaving aside quality loss due to interpolation of course).
Please be aware then that I was not looking for the best looking result, just a solution that is totally math consistent with the projection the tilt-shift lens would have achieved when facing the same situation and being shifted.

The result was OK (I insist, leaving aside the loss of quality due to interpolation and the logical need of crop):




I did 3 steps:
1. Rotation correction so the image was aligned with the plane in which the tilt of the wide angle was to be corrected.
2. Use the tool "perspective" to correct perspective in order to get parallel lines where lines should be parallel (sides of the stereo loudspeaker)
3. Correct scale in Y-axis so that proportions in it are correct (I seeked for a perfect circle for the loudspeakers).

Now the bad news: to achieve that was terribly painful:
1. The lens correction tool could have worked fine fine but I could not use it since the maximum vertical perspective correction (100) was not enough for my extreme image.
2. I used then the "perspective" tool, and it worked, but was really difficult to achieve parallel lines since it starts to behave curve when high correction values are applied.
3. The final stage, Y-scaling, could properly be done thanks to the 1x1 proportions of the loudspeakers. If the scene had not such references, how should we ensure we are obtaining the only mathematically correct solution?
4. Any other tool but "perspective" (free transform, distort, scale,...) were simply not valid even in the basic task of obtaining a symmetrical left-to-right horizontal correction or at least I didn't manage to make them work for my purpose.

Questions:
1. What is your procedure in PS to correct perspective? (please bear in mind my goal: obtain mathematically the same projection as would have achieved with a tilt-shift lens pointed 90º to the target and shifted to accomodate the field of view)
2. What other software is good for perspective correction? I am specially interested in a good interpolation achieved if possible in only one step, wich I am sure is conceptually possible since only one parameter is really playing into the game: the angle with respect to the subject in which we tilted the wide angle lens when shooting the scene (assuming we did no camera rotation as I did in my example).

Thanks
« Last Edit: February 10, 2008, 07:07:49 am by GLuijk »
Logged

Panopeeper

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1805
Is perspective correction in PS so painful?
« Reply #1 on: February 10, 2008, 11:23:24 am »

Guillermo,

do you care uploading the original somewhere?
Logged
Gabor

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Is perspective correction in PS so painful?
« Reply #2 on: February 10, 2008, 12:13:07 pm »

Quote
Guillermo,

do you care uploading the original somewhere?
[{POST_SNAPBACK}][/a]

Here you are: [a href=\"http://www.guillermoluijk.com/download/perspective.cr2]http://www.guillermoluijk.com/download/perspective.cr2[/url]

But think my main concern is not to solve this particular case, but to find an operative way to correct perspective in PS. I have used another alternative and the result has been great, in just one step it did everything: rotation, perspective correction and proper Y-scaling, I used the crop tool with the Perspective option ON:



Unfortunately:
1. It took a large time to do it (about 10mins)
2. I have used it again in some other examples and although it corrected OK the perspective, it needed final Y-scaling. So I guess the first try was just luck, PS does not do the needed calculations for a proper Y-scaling in one step, that I am sure they are truly possible.


Regards.
« Last Edit: February 10, 2008, 12:14:32 pm by GLuijk »
Logged

Panopeeper

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1805
Is perspective correction in PS so painful?
« Reply #3 on: February 10, 2008, 02:00:46 pm »

For me this is not a Photoshop task; of course, I am biased.

A Panorama Tools based stitcher does the job perfectly, though not with less labour than in Photoshop. On the other hand, the result is more or less curvilinear corrected (barrel, pincussion), depending on the image and the labour invested in the setup, and the image quality is principally better than PS, for

1. one can select the interpolation method,

2. warping and resizing is in a single pass, i.e. no extra interpolation is involved.
Logged
Gabor

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Is perspective correction in PS so painful?
« Reply #4 on: February 10, 2008, 03:28:45 pm »

I was just now trying Hugin (a PTools GUI) and honestly, I don't get it to work.

I have tried the Egypt stone found in this sample tutorial: http://wiki.panotools.org/Perspective_correction, which seems to be the same as this other tutorial, and I don't get the same result as there.

Several times I have set 4 vertical control points and 4 horizontal control points which should define the 2 vertical and 2 horizontal control lines that the program needs to obtain this and I only get shit (or something worse).

PT doesn't seem appropiate to correct perspective since it expects 2 or more images, so control points have to be set twice (and manually edited if we want them to perfectly match).
And in any case I don't get the same result as the authot of the tutorial, I wonder how he did as I followed all the steps.

On the other side PTLens (not Panorama Tools) has a great perspective correction, but has the problem that it crops the result so it is not the user who decides which portion of the original image will participate in the final image.

I really feel a bit disappointed with all this as I think correct perspective correction is a very clearly specified task, and no program seems to really achieve it properly.

In your sample, the horizontal perspective has not been 100% corrected, if you look at the base of the loudspeaker it is not completely horizontal. Did you choose the crop of PTGUI forced it? Hugin at least allows to choose if any crop is to happen.

Regards.
« Last Edit: February 10, 2008, 03:31:25 pm by GLuijk »
Logged

MichaelEzra

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1146
    • https://www.michaelezra.com
Is perspective correction in PS so painful?
« Reply #5 on: February 10, 2008, 03:51:17 pm »

Give a try to AutoPano.net
Logged

Panopeeper

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1805
Is perspective correction in PS so painful?
« Reply #6 on: February 10, 2008, 04:22:08 pm »

Quote
Give a try to AutoPano.net
You are in good humour.
Logged
Gabor

Panopeeper

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1805
Is perspective correction in PS so painful?
« Reply #7 on: February 10, 2008, 04:39:34 pm »

Gullermo,

some misconceptions need to be cleaned up.

1. Perspectivic distortion is, when parallel lines are closing in distance; for example the top of a tall building appears much narrower that the bottom, if you see it from street level.

2. Lines, which are horizontal in reality, are horizontal on a picture *only* if the shot is made *perpendicularly* to that line. It is seldom in panorama making, that you can specify a horizontal line.

3. Tilt ans shift lenses are correcting the perspectivic distortion, but they are not making non-horizontal lines horizontal. Forcing a non-horizontal line to be horizontal introduces distortions on its own.

4. Panorama Tools always works on individual images; creating a complete image out of the individually warped ones is an extra step, usually done separately with a specialized blender, like Enblend, Smartblend.

Of course it can warp an image on its own.

5. Vertical lines occur very often in images (though not enough in landscapes). If you have several vertical lines, PT will calculate the correct position of the image.

6. You can specify straight lines (horizontals, which do not appear horizontal, are good too, for example the bottom of the sofa). This helps PT's optimizer to calculate the curvilinear distortion of the lens, which then will be corrected in the warping phase.

With following parameters you should be able to warp the image like I did:

###############################################
# Panorama Output Settings:
p w1007 h2450 f0 u0 v132.1 n"JPEG q90"


# Stitcher mode settings: (modify as needed)
m i1 g1 f0

# Source Image File Data:
#-imgfile 2304 3456 "K:\$_Panorama\PerspectiveCorrection\Guillermo_perspective.TIF"
o  f0 y-3.98167 p-26.5563 r31.3025 v73.0577 a0.006315 b-0.023476 c0 d0 e0 g0 t0


# Control Point Information:
# (Do not re-order these)
c n0 N0 x305 y33 X927 Y1127 t1
# Control Point No 1: 6.38682E-03
c n0 N0 x742 y245 X1321 Y1414 t1
# Control Point No 2: 5.14533E-03
c n0 N0 x745 y251 X1318 Y1407 t3
# Control Point No 3: 0.166863
c n0 N0 x841 y446 X1036 Y841 t3
# Control Point No 4: 0.166863
c n0 N0 x974 y717 X1220 Y1213 t3
# Control Point No 5: 0.248496
c n0 N0 x9 y2811 X1220 Y2081 t4
# Control Point No 6: 0.0339121
c n0 N0 x192 y2701 X1059 Y2179 t4
# Control Point No 7: 0.0339121
c n0 N0 x376 y2592 X841 Y2311 t4
# Control Point No 8: 0.128972
c n0 N0 x549 y2488 X699 Y2397 t4
# Control Point No 9: 0.126896

# Morph-to-fit Information:
# (Do not re-order these)

# Optimizer Settings Information:
v p0 r0 y0 a0 b0 c0 d0 e0 g0 t0 v0
#
# End of script
###############################################
Logged
Gabor

Jonathan Wienke

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 5829
    • http://visual-vacations.com/
Is perspective correction in PS so painful?
« Reply #8 on: February 10, 2008, 04:55:11 pm »

I use PTAssembler, a GUI for Panorama Tools. It has options for setting the horizon of the stitched panorama, you can raise and lower the horizon line (which does vertical perspective adjustment) as well as tilt it (which rotates the entire panorama) to correct for almost any perspective distortions you may encounter.
Logged

Dan Kanagy

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
Is perspective correction in PS so painful?
« Reply #9 on: February 10, 2008, 04:55:23 pm »

Guillermo,

I use PTGui to get the numbers for correcting yaw, pitch, and roll and then feed those numbers to the Panorama Tools plugin (Perspective filter) for Photoshop.  This produces reliable results.  Note that you can set vertical line control points in PTGui for a single image by setting the left coordinate in one window and the right coordinate in the other. The positive corrections reported by PTGui should be made negative in Panorama Tools and vice versa.
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Is perspective correction in PS so painful?
« Reply #10 on: February 10, 2008, 06:02:17 pm »

Quote
2. Lines, which are horizontal in reality, are horizontal on a picture *only* if the shot is made *perpendicularly* to that line. It is seldom in panorama making, that you can specify a horizontal line.

I agree. Consider however that in that image, even if the sofa and loudspeaker bottom and top lines are not horizontal, they are parallel. I did it intentionally just by ensuring the direction of observation was contained in a plane perpendicular to the audio system and couch front faces. I simply added a final rotation variable to make things a bit mor challenging to PS.

That's why I find a bit strange your result, where the couch and loudspeaker bottom and top front lines do not remain parallel any more but have gained perspective.



Thanks all for the recommendations, it seems PT is the answer, although I will try GUI's different to Hugin.
« Last Edit: February 10, 2008, 06:03:17 pm by GLuijk »
Logged

walter.sk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1433
Is perspective correction in PS so painful?
« Reply #11 on: February 10, 2008, 06:54:18 pm »

There is a plugin for Photoshop called Image Align Pro, by Grasshopper.   I have been unable to locate a working link for them, but I have been using their program for many years.

In addition to the usual barrel and pincushion corrections, rotation, vertical and horizontal perspective distortion corrections, the program also has corrections for vertical and horizontal skew.  Everything works by simple sliders.  This filter has saved many a seemingly hopelessly distorted image for me.  Try a Google search.  You might have better luck than I did at finding the website, which should have a trial version to download.
Logged

Panopeeper

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1805
Is perspective correction in PS so painful?
« Reply #12 on: February 10, 2008, 07:16:05 pm »

Guillermo,

1. I did not state, that these were not horizontal or parallel. I said only that it is not obvious. If you do know, that the sofa was perpendicular to the axis of the lens, you can specify that as horizontal. In fact I made such a version, but I was not sure if that was supposed to be so. The one I posted had some "freedom" in it, i.e. more parameters can be added without inducing contradictions.

2. Hugin, PTGui and PT Assembler are all PT based. I favour the last one, but that's only the UI, the meat is the same.

Hugin is free; I don't know the user interface. PTAssembler costs $39, PTGui much more, without being better.

On the other hand, Walter's suggestion may be much simpler, if you are not in panos otherwise.
« Last Edit: February 10, 2008, 07:17:21 pm by Panopeeper »
Logged
Gabor

HarperPhotos

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1309
    • http://www.harperphoto.com
Is perspective correction in PS so painful?
« Reply #13 on: February 10, 2008, 08:01:11 pm »

Hello,

Unfortunately Image Align is no longer manufactured in New Zealand any more.
The owner of Grasshopper told me he could not afford to make his plug in compatible for CS3 and decided to call in quits which is very unfortunate as it runs circles around Adobe's poor excuse of perspective control soft wear.

Cheers

Simon
Logged
Simon Harper
Harper Photographics Ltd
http://www.harperphoto.com
http://www.facebook.com/harper.photographics

Auckland, New Zealand

Christopher

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1499
    • http://www.hauser-photoart.com
Is perspective correction in PS so painful?
« Reply #14 on: February 10, 2008, 09:05:30 pm »

Here is a quick one in PTGui, took me around 5 minutes.

Not 100% perfect, but I think it works for me.

[attachment=5097:attachment]
Logged
Christopher Hauser
[email=chris@hauser-p

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Is perspective correction in PS so painful?
« Reply #15 on: February 10, 2008, 09:28:31 pm »

Quote
Here is a quick one in PTGui, took me around 5 minutes.

Not 100% perfect, but I think it works for me.

[attachment=5097:attachment]
[a href=\"index.php?act=findpost&pid=173866\"][{POST_SNAPBACK}][/a]

Harper and Christopher thanks for your effort. I will give a try PTGUI.
But I want to ask an additional question looking at your version Christopher. This is a 300% crop of it; even if the definition after your resizing is not ideal for proportion checks, I can see the loudspeakers are not perfectly round. In a mathematically correct perspective correction they should be, since they were laying on the plane that we took as a reference for the perspective correction (the audio column front face):


(right loudspeaker is a 90º rotated version of the other one)

In PS I adjusted this trhough manual Y-scaling, but this is not appropiate at all since not all scenes will have some perfecly square or round element to compare.

So I wonder if PTGUI allows to make sure the correction is perfect without needing the user to assist it in the Y-axis scaling?
This is very important since although in some perspective correction tutorials (with PS) they assume the user will adjust the Y-scaling in the end just by looking at the image and deciding subjectively it is nice, this is not the proper way to correct emulate the result we would have achieved with a shifted tilt-shift lens. And in addition to that it will be simply impossible to do it in scenes with such a square/round element. Not chosing the right Y-scaling simply means we are compressing/expanding our whole image along that axis, and this is unacceptable.


BR
« Last Edit: February 10, 2008, 09:32:40 pm by GLuijk »
Logged
Pages: [1]   Go Up