Page 1 of 1

Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-27T09:43:25-07:00
by tackd
Hi.

This image was shot at a slant with a Tilt-Shift applied either with software or a Tilt-Shift lens
to correct vericals straight.

Image

Photoshop straightening,perspective correction tools did not fare well with this image.
I fear a re-shoot will need to be done.

Is there any way IM can be used to straighten out the bottom slanted and distorted perspective ?

Thank you much.

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-27T10:05:01-07:00
by snibgo
The house is built on the side of a hill. The house is horizontal, and the road runs downhill from left to right. To get everything square, you should rebuild the house on flat land.

The image could be sheared to move the right side upwards, making the road horizontal but then house would look weird.

"-distort perspective" can make everything more square, eg:

Code: Select all

magick ^
  uaE0Qe.jpg ^
  -distort Perspective 0,0,0,0,639,0,639,0,55,307,55,307,572,314,572,314,0,380,0,425,637,425,637,425 ^
  hillhouse.jpg
Image

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-27T11:11:18-07:00
by tackd
snibgo,

I'm seriously impressed at what you did, would you please allow me a curious request...,
this is a beautiful result but is it possible to correct the distortion of the downward bend in the sidewalks to be a little more straight ?

I'll consider rebuilding the House on flat land if you will consider teaching me how you did the correction (wink) !

Extremely well done.

Thank you so much.

Regards.

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-27T11:36:54-07:00
by fmw42
Did you use a wide angle lens? If so that is likely the cause of the sidewalk bend. The perspective distortion that snibgo used will not correct that. You would need to add another distortion to correct the barrel/pincushion caused by the wide angle, I suspect. But snibgo is more versed on photography corrections that I. So I will defer to him on this.

See https://imagemagick.org/Usage/distorts/

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-27T11:41:21-07:00
by snibgo
tackd wrote:... to correct the distortion of the downward bend in the sidewalks to be a little more straight ?
The curve is in your input image. I used "-distort perspective", which preserves colinearity. This means that straight lines in the input remain straight in the output, and curved lines remain curved. We can't correct curves with "-distort perspective".

The curve may be because the road is like that, or because the camera lens has pincushion distortion. In any case, we can apply barrel distortion:

Code: Select all

magick ^
  uaE0Qe.jpg ^
  -distort barrel 0,0,0.04 ^
  -distort Perspective 0,0,0,0,639,0,639,0,55,307,55,307,572,314,572,314,0,380,0,425,637,425,637,425 ^
  hillhouse.jpg

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-27T13:02:29-07:00
by tackd
Brilliant !

I tried to emulate your code;

Code: Select all

convert 002-10-Exterior-Front.jpg -distort barrel 0,0,0.04 -distort Perspective 0,0,0,0,639,0,639,0,55,307,55,307,572,314,572,314,0,380,0,425,637,425,637,425 hillouse.png
Looks good, except there is tearing on the right side...

Image

Did I do the code correctly ?

Regards.

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-27T13:17:37-07:00
by snibgo
There is "tearing" on all four sides. They are from virtual pixels. Insert "-virtual-pixel Black" before the first distortion to see them more clearly.

The solution is to crop the result. See my Inner Trim, or Fred's innercrop for a different method.

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-27T22:26:38-07:00
by tackd
Thank you very much for your expertise.

I had another question that popped up.

In a similar fashion to how panorama stitching software works...

Could the straightened sidewalk of your 2nd barrel correction image be merged with your 1st perspective correction,
e.g. sidewalk and below from image 2, above sidewalk from image 1 ?
Similar to how one stitches a vertical panorama.

Maybe I'm reaching too far, but curious I am !

Regards.

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-28T16:07:30-07:00
by tackd
2nd thought, never mind the last post on stitching two images, seems far fetched.

Your first correction before the barrel distortion to correct perspective looks so good.
Is IM able to apply the barrel correction to the bottom part of the image (sidewalk and below) or
does it have to be applied to the center of the image.

Thank you.

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-28T16:40:41-07:00
by snibgo
An image can be composited over another same-size image with a mask that is white where we want the second image, black where we want the first, and gray for a blend.

So that is one way of getting a result using pixels from one image at the top and from the other image at the bottom, with a blend in the middle.

Blending geometric distortions (like barrel and perspective) is slightly more complex, because these don't change pixels, these move pixels. So at the blend, you want to move pixels by some intermediate result.

To get blended displacements, you can use displacement maps. Create an identity absolute map and distort it in the two ways. Invert both maps. Create the black-gray-white mask. Composite one map over the other with the mask, and invert the result back. This gives a blended absolute displacement map that you can use to displace your source image.

EDIT: I forgot to mention the inversions in the previous paragraph. A normal map has for each destination pixel a pointer to where the pixel came from. Inverting changes this, so that each source pixel points to where it moves to. For the blending to work as we want, we need the inversions.

Re: Correction To Tilt-Shift Real Estate Image...

Posted: 2018-10-28T16:53:51-07:00
by tackd
Whoa snibgo !

Dizzy, I am.

Genius plan. Way beyond my basic wrapping textures around an image using displacement maps.

Hats off to you just the same.

Take good care, thanks again.