Simulating lens tilt on image

I am currently trying to simulate the effect of lens tilt on a flat image (i.e., one that does not contain multiple depths of field). The lens would be tilted in both RX and RY, so in a direction not aligned with the plane of the photo.
Is there currently anything within the image processing tool box that does this? If not, is there a known algorithm to produce the effect of the tilted plane of focus?

5 Comments

So effectively different point-spread-functions in different parts of the image? If so how "optically accurate" do you require the psf to be, and what types of aberrations does your lens/lens-model have?
David H
David H on 9 Jun 2020
Edited: David H on 9 Jun 2020
I'm happy to assume a thin lens free of aberrations and the psf could be a Gaussian or a circle, I just want to get some idea of the impact on the image.
To get the width of the PSF I used : to related the size of the circle of confusion c and the image distance y_x (from https://en.wikipedia.org/wiki/Scheimpflug_principle), so I guess I could approximate the PSF to apply to any position on the image as being approximately
PSF = @(x,y,c) 1/ c * exp(-(x.^2+y.^2) /(2*c^2))
with "c" some function of the position in the image and the tilt about RX and RY.
The issue now is that I can't apply a simple convolution with the image, and anything I can think of is numerically very expensive. I know you can simulate lens tilt in photoshop so there must be an easier way.
I realise there are some issues with normalisation and using diameter rather than radius in that point spread function, just giving a flavour of my problem.
David, for your well-behaved psf I have a computationally fairly OK solution. It is based on converting the 2D-smoothing-operations into a pair of 1-D sparse matrix operations. The sparse matrices takes some time to build up, but the actual smoothing is very rapid. Since you have Gaussian kernels repeated smoothing with a narrow Gaussian results in a smoothing with a wider Gaussia you might be able to get away with less of the start-up-times.
Did the suggestions from Image Analyst and me help? The two suggestions should take care of both perspective effects and PSF-variations.

Sign in to comment.

Answers (2)

Bjorn Gustavsson
Bjorn Gustavsson on 10 Jun 2020
OK, here's a two thirds (some reasonable-fraction) solution that computationally is not too shabby. In its current version it allows for a combination of horizontal smoothing that varies in the vertical image-direction and a vertical smoothing that varies in the horizontal direction. It builds separate sparse smoothing-matrices for each separate direction, this takes a bit of time, the actual smoothing is then only a pair of vector-sparse-matrix ultiplications and rather efficient. I think this is approximately what you need - your Gaussian PSFs are trivially separable (10 s of Gauss-aweing) so that should be fine, the function should be expanded to allow for smoothings that varies at least as Kxx, Kxy, Kyy, and Kyx. It might be possible to be very clever and come up with a decomposition of more general PSF - similar to what is used in convolve2, but that is TBD.
HTH

Products

Release

R2020a

Asked:

on 9 Jun 2020

Commented:

on 17 Jun 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!