cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

How to do Bilinear Interpolation using JMP?

smostafa
Level I

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

FileFrameXYColor
Antman100255
Antman155195
Antman132??
Antman200255
Batman300255
Batman332??
Batman355100




1 REPLY 1
ian_jmp
Level X


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.

Recommended Articles

No recommendations found