1
$\begingroup$

I am following a paper on computationally modeling optical phenomena within a lens. (https://resources.mpi-inf.mpg.de/lensflareRendering/) At some point they use the Fourier power spectrum of an aperture image to generate an image of the refractive phenomenon known as a "starburst". From the paper:

Assuming a uniform incident distribution of parallel (collimated) light (at wave- length λ) and a real-valued amplitude transmission function T (x, y), the Fraunhofer pattern T 0 (x0 , y 0 ) in an observation plane at distance z0 from the aperture is given by the Fourier power spectrum of T.

I am rendering my polygonal aperture as a pixel image and using an FFT of it for the starburst. I quickly found out that I have to pad my aperture image with a lot of zeroes for an acceptable result to avoid artifacts from the assumption of a periodic input signal for an FFT. Currently I am making my image roughly four times as large as the aperture:

Aperture with zero-padding

But I am still getting artifacts that look like mirror images of the "rays" on the edges of my power spectrum: Fourier power spectrum of padded image

I suspect that I will always get those in some way, no matter how much padding I add. Both more padding and scaling down the aperture further will sooner or later get impractical due to constraints on either memory and computing time or achievable quality.

Is there some alternative transform or approach I can use, that avoid these artifacts or at least the memory overhead of padding the aperture image with a massive amount of zeroes?

I am using Python and Numpy, big plus for a solution using those tools only. I do not mind cutting off some of the rays at the border of the spectrum, but I cannot have their "reflections" in the result.

$\endgroup$
3
  • $\begingroup$ What would happen if your aperture was circular? Would you get any starburst at all? $\endgroup$ Aug 17, 2023 at 21:13
  • 1
    $\begingroup$ In theory, this: en.wikipedia.org/wiki/Airy_disk . In practice, I haven't tested it yet. $\endgroup$
    – geloescht
    Aug 17, 2023 at 21:25
  • $\begingroup$ You'll have the same problem with aliasing if you use the FFT. You can approximate an Airy disk, but for an exact Airy disk you need to solve the spatially-continuous Fourier transform symbolically. $\endgroup$
    – TimWescott
    Aug 18, 2023 at 16:45

1 Answer 1

1
$\begingroup$

This is not because of lack of padding, or periodicity assumptions. What you are seeing is aliasing. You defined your input image as the sampling of an infinitely sharp object, which has infinitely high frequencies. Sampling this object creates aliasing, which you see as the tips of your star folding over in the frequency domain.

To overcome this define your object to have smoother transitions from bright to dark, so that it’s bandlimited, or simply multiply the frequency domain with some low-pass filter (setting larger frequencies to zero will hide most of the effects of aliasing in this case). This latter approach is not as nice, but a lot easier to implement.

For the former approach, I like to use the error function on a distance map. Create an image where the the edges of the aperture are 0, inside the aperture you have increasing values away from the edge, and outside you have decreasing values away from the edge. Applying the error function as a mapping to this image will give you a nicely bandlimited image with a pretty Fourier transform.

$\endgroup$
1
  • 1
    $\begingroup$ Increasing anti-aliasing from 1px to 2px width and switching from a simple linear clamp function to erf indeed supressed the reflections to a barely noticable level (Luckily I was already using a signed distance field to define the aperture image). Subsequently getting rid of the padding again improved the result further. Thank you! $\endgroup$
    – geloescht
    Aug 17, 2023 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.