help-octave
[Top][All Lists]

## Re: How can I do to interpolate an image using bilinear interpolation or

 From: James Sherman Jr. Subject: Re: How can I do to interpolate an image using bilinear interpolation or nearest neighbor? I would not use any function of the package image. Date: Sun, 16 Dec 2012 22:32:58 -0500

```On Sun, Dec 16, 2012 at 10:01 PM, eduardo silva <address@hidden> wrote:
> I need to work out pixel by pixel.
>
> I want the user to enter the scale that it will use to enlarge the image (x
> and y coordinates), so I can calculate the size of the output. But I do not
> see how to traverse the array output and set its pixels. Should I call the
> function interp2 for each pixel output?
>
> Researched function interp2 but am confused with the parameters needed. Can
> you give me an example of using?
>
> Image on the package, I would not use it, I understand the interpolation.
>
>
>
> --
> View this message in context:
> http://octave.1599824.n4.nabble.com/How-can-I-do-to-interpolate-an-image-using-bilinear-interpolation-or-nearest-neighbor-I-would-not-us-tp4647984p4647998.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> https://mailman.cae.wisc.edu/listinfo/help-octave

Here would be one way to use interp2:
=====
[xx, yy] = meshgrid([-2:.1:2]);
zz = 1./(xx.^2+yy.^2+1);

[xxi, yyi] = meshgrid([-2:.05:2]);
new_zz = interp2(xx, yy, zz, xxi, yyi, 'nearest');
=====
or like this:
x_scale = 2;
y_scale = 3;

[xx, yy] = meshgrid([-2:.1:2]);
zz = 1./(xx.^2+yy.^2+1);

[xxi, yyi] = meshgrid(1:(1/x_scale):size(zz,1), 1:(1/y_scale):size(zz,2));
new_zz = interp2(zz, xxi, yyi, 'nearest');
=====

Hope this helps,

James Sherman Jr.

```