From: Bjorn Gustavsson on
"Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hoqb55$fd8$1(a)fred.mathworks.com>...
> "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hop5s0$a8j$1(a)fred.mathworks.com>...
> > "Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hoot0q$4bp$1(a)fred.mathworks.com>...
> > > Hello.
> > > I have a 1D function which I want to interpolate into 2D function.
> > > I know the function should have "Polar Symmetry".
> > > Hence I use the following code:
> > > Assuming the 1D function is LSF of the length 15.
> > >
> > > [x, y] = meshgrid([-7:7]);
> > > r = sqrt(x.^2 + y.^2);
> > > PSF = interp1([-7:7], LSF, r(:)); % Sometimes using 'spline' option, same results.
> > >
> > > PSF = reshape(PSF, [7, 7]);
> > >
> > > I have few problems:
> > > 1. Got some overshoot at the edges.
> > > 2. Can't enforce some assumptions (Monotonic, Non Negative).
> > ================
> >
> > Linear interpolation should satisfy all these properties.
>
> No it doesn't.
> I'll show you.
>
> Let's create a 2d Gaussian Kernel:
> h = fspecial('gauss', 15, 3);
>
> Now let's take a 1D profile of it:
> LSF = h(8, :);
>
> Let's apply the linear algorithms:
>
> [x, y] = meshgrid([-7:7]);
> r = sqrt(x.^2 + y.^2);
> PSF = interp1([-7:7], LSF, r(:));
> PSF = reshape(PSF, [7, 7]);
>
> The results (Added "Spline" and 'Pchip"):
> http://i43.tinypic.com/auxyxi.png
>
> As you can see at the edges there's "Overshoot" (Especially in "Spline"). The linear method gets negative values and changes the form.
>
> Thanks.

Yes, because your PSF is defined for r = [-7:7] and you use interp1 on it for radii up to 7*2^0.5 -> you extrapolate. If you take this into account in some cunning way you should be fine.

HTH,
Bjoern
From: Matt J on
"Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hoqb55$fd8$1(a)fred.mathworks.com>...

> The results (Added "Spline" and 'Pchip"):
> http://i43.tinypic.com/auxyxi.png
>
> As you can see at the edges there's "Overshoot" (Especially in "Spline"). The linear method gets negative values and changes the form.
==================

You might want to look at my interpMatrix tool, which allows you to specify some different extrapolation rules, as well as to choose whatever interpolation kernels you like

http://www.mathworks.com/matlabcentral/fileexchange/26292-regular-control-point-interpolation-matrix-with-boundary-conditions

It has some examples showing how to interpolate using cubic B-Splines, but which avoid overshoot by applying mirror boundary conditions.

I don't really understand what you mean by "monotonic". Since your Gaussian is a non-monotonic function, you are not looking for a monotonic curve, nor would you want interpolated values between points to be montonic.

You mean you want extrapolation at the edges to run montonically down to zero?
From: Royi Avital on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hoqdfi$sjt$1(a)fred.mathworks.com>...
> "Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hoqb55$fd8$1(a)fred.mathworks.com>...
>
> > The results (Added "Spline" and 'Pchip"):
> > http://i43.tinypic.com/auxyxi.png
> >
> > As you can see at the edges there's "Overshoot" (Especially in "Spline"). The linear method gets negative values and changes the form.
> ==================
>
> You might want to look at my interpMatrix tool, which allows you to specify some different extrapolation rules, as well as to choose whatever interpolation kernels you like
>
> http://www.mathworks.com/matlabcentral/fileexchange/26292-regular-control-point-interpolation-matrix-with-boundary-conditions
>
> It has some examples showing how to interpolate using cubic B-Splines, but which avoid overshoot by applying mirror boundary conditions.
>
> I don't really understand what you mean by "monotonic". Since your Gaussian is a non-monotonic function, you are not looking for a monotonic curve, nor would you want interpolated values between points to be montonic.
>
> You mean you want extrapolation at the edges to run montonically down to zero?

Yep, This is exactly what I want.
To enforce some assumptions on the Extrapolation, it must be Non Negative and Monotonic.
Any solution for that?
Thanks.
From: Matt J on
"Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hoqioe$31d$1(a)fred.mathworks.com>...

> Yep, This is exactly what I want.
> To enforce some assumptions on the Extrapolation, it must be Non Negative and Monotonic.
> Any solution for that?
=================

And why, as suggested in an earlier post, don't you just generate LSF data on a wider interval? Then you wouldn't have to extrapolate at all.
From: Royi Avital on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hotole$cv5$1(a)fred.mathworks.com>...
> "Royi Avital" <RoyiREMOVEAvital(a)yahoo.com> wrote in message <hoqioe$31d$1(a)fred.mathworks.com>...
>
> > Yep, This is exactly what I want.
> > To enforce some assumptions on the Extrapolation, it must be Non Negative and Monotonic.
> > Any solution for that?
> =================
>
> And why, as suggested in an earlier post, don't you just generate LSF data on a wider interval? Then you wouldn't have to extrapolate at all.

I don't understand what you mean.
If the size of the LSF support is 1X15 I need it on 2D domain with support of 15X15.

I can assume Monotonic Decreasing and Non Negative and needless to say, Rotational Invariance.

How should I do it?