The World Statistics Day celebration continues here in the Community. We all need reliable data for sound decision making. Do you have a data source that you trust most? Head over to Discussions to tell us about it.
Choose Language Hide Translation Bar
Highlighted
Level I

## How to do Bilinear Interpolation using JMP?

Essentially it is called 2D multivariate interpolation. I have set of locations (x,y) and a corresponding data eg: z=color value. For some of the (x,y) the z column has data missing. I want to use the nearest two known ( x1,y1,z1) and (x2,y2,z2) to interpolate the value for (x3,y3, z3=?).

Theoretically this wiki/Bilinear_interpolation is what I like to get.

Does JMP has a way of doing this?

Also I need first group the X,Y data by two other column A,B. Example. COl A,B represents filename and frame number. X,Y is the location of a pixel in the frame and Z is the pixel color.

I want to interpolate the Z value for missing pixels in each frame in each file.
Sample Data set

 File Frame X Y Color Antman 1 0 0 255 Antman 1 5 5 195 Antman 1 3 2 ?? Antman 2 0 0 255 Batman 3 0 0 255 Batman 3 3 2 ?? Batman 3 5 5 100

1 REPLY 1
Highlighted
Staff

## Re: How to do Bilinear Interpolation using JMP?

If I understand correctly, you will need four points (not two) for the bilinear interpolation. The grouping columns would be wasily dealt with, so for one group you could do something like:

``````Names Default To Here( 1 );

// Example table: Four complete observations, and one missing 'Colour' to be
// obtained by bilinear interpolation
dt = New Table( "Antman_1",
Add Rows( 5 ),
New Column( "X",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [0, 5, 3, 5, 0] )
),
New Column( "Y",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [0, 5, 2, 0, 5] ),
Set Display Width( 92 )
),
New Column( "Colour",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [255, 195, ., 100, 150] )
)
);

// Using the notation at: https://en.wikipedia.org/wiki/Bilinear_interpolation
x1 = dt[1, "X"];
x2 = dt[2, "X"];
y1 = dt[1, "Y"];
y2 = dt[2, "Y"];
q11 = dt[1, "Colour"];
q21 = dt[4, "Colour"];
q12 = dt[5, "Colour"];
q22 = dt[2, "Colour"];
x = dt[3, "X"];
y = dt[3, "Y"];

// Interpolate in the X direction
r1 = Interpolate(x, x1, q11, x2, q21);
r2 = Interpolate(x, x1, q12, x2, q22);

// Interpolate in the Y direction
p = Interpolate(y, y1, r1, y2, r2);
Wait(3);
dt[3, "Colour"] = p;``````

This is unlikely to be the 'best' way, but to do better some sample data (in a JMP table) would be required. You would also need to decide how to handle edge cases.

Article Labels

There are no labels assigned to this post.