Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDIT: based on your clarification, it's clear what's going on. You are trying to interpolate a function beyond the range of available data -- i.e. you are going from interpolation to extrapolation. Splines are going to result in the overshoot that you are observing. The solution is simply to make sure that your 1D function has values in the interval [min(r), max(r)]. Note that in the original data, max(r) is about 424, while the function you are interpolating is defined on the range [-300,299]</p> <pre><code>% Simulated overshoot, see left figure: x1d = [-300:299]; [x,y]=meshgrid(x1d,x1d); r = sqrt(x.^2+y.^2); gsn1d = exp(-x1d.^2/500); lowpass = @(x)(x1d &gt; -x &amp; x1d &lt; x); gsn1dcutoff = ifft(fftshift(lowpass(10).*fftshift(fft(gsn1d)))); plot(gsn1dcutoff) OTF2d = reshape(interp1(x1d,gsn1dcutoff,r(:),'spline'),[length(x1d),length(x1d)]); mesh(OTF2d) % Quick and dirty fix, see right figure: x1dExtended = linspace(min(x1d*sqrt(2)),max(x1d*sqrt(2)),ceil(length(x1d)*sqrt(2))); gsn1dE = exp(-x1dExtended.^2/500); % ^^^ note that this has 600*sqrt(2) points and is defined on the diagonal of your square. Now we can low-pass filter in the freq. domain to add ripple in space domain: lowpass = @(x)(x1dExtended &gt; -x &amp; x1dExtended &lt; x); gsn1dcutoff = -real(ifft(fftshift(lowpass(10).*fftshift(fft(gsn1dE))))); plot(gsn1dcutoff) OTF2d = reshape(interp1(x1dExtended,gsn1dcutoff,r(:),'spline'),[length(x1d),length(x1d)]); mesh(OTF2d) </code></pre> <p><a href="http://img54.imageshack.us/img54/8255/clipboard01vz.png" rel="nofollow noreferrer">alt text http://img54.imageshack.us/img54/8255/clipboard01vz.png</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COOk, Actually OTFx is estimated from an image, yet it's identical up to a constant and epsilon to a "Gaussian". Try the following to replicate it. Create a Gaussian of length 21. Convert it using fft with zero padding to the length 600. Try to interpolate it to have a 2D Gaussian as you would convert 2D Gaussian into frequency domain. The question is, Is there an alternative way doing it? Maybe a better algorithm, Applying some Constraints etc... It's something similar to "Ringing" effect. Thanks.
      singulars
    2. COSee my updated answer. I don't think other interpolation algorithms will be better at extrapolating beyond available data, but feel free to look up help for interp1 and play with different algorithms. The main point is: to avoid surprises, make sure you are providing sufficient data for interpolation.
      singulars
    3. COThank you for you response. Maybe if I shed some more light on the problem you may assist me even more. The interpolated function must be positive everywhere. Generally it should be Monotonic Descending. I'm starting with something similar to 1D Gaussian of the length 21 then "FFT" it into 600 (Or whatever length I want using zero padding). What I want is the best 600X600 2D interpolation of it in the Frequency Domain. As a test case we can take a "Pure" 1D Gaussian of the length 21 and try to interpolate it as close as possible to 600X600 2D DFT of 21X21 2D Gaussian. Thanks.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload