interpolation

Interpolation of time series data in R

I'm not sure what i'm missing here, but i'm basically trying to compute interpolated values for a time series; when I directly plot the series, constraining the interpolation points with "interpolation.date.vector", the plot is correct: plot(date.vector,fact.vector,ylab='Quantity') lines(spline(date.vector,fact.vector,xout=interpolation...

3d geometry: how to interpolate a matrix

hello, i store the position of an object in 3d space in a 4by4 transformation matrix. now in order to move the object from the position stored in matrix A to the position stored in matrix B, i would like to interpolate them. so do i just do this by interpolating each of the 16 values in the matrix, or do i have to take special care abo...

Inverse Distance Weighted (IDW) Interpolation with Python

The Question: What is the best way to calculate inverse distance weighted (IDW) interpolation in Python, for point locations? Some Background: Currently I'm using RPy2 to interface with R and it's gstat module. Unfortunately, the gstat module conflicts with arcgisscripting which I got around by running RPy2 based analysis in a separate...

How do I choose an image interpolation method? (Emgu/OpenCV)

The image resizing function provided by Emgu (a .net wrapper for OpenCV) can use any one of four interpolation methods: CV_INTER_NN (default) CV_INTER_LINEAR CV_INTER_CUBIC CV_INTER_AREA I roughly understand linear interpolation, but can only guess what cubic or area do. I suspect NN stands for nearest neighbour, but I could be wrong...

Interpolation over an irregular grid

So, I have three numpy arrays which store latitude, longitude, and some property value on a grid -- that is, I have LAT(y,x), LON(y,x), and, say temperature T(y,x), for some limits of x and y. The grid isn't necessarily regular -- in fact, it's tripolar. I then want to interpolate these property (temperature) values onto a bunch of dif...

Linear interpolation on a numpy array

I have the following numpy array: # A B C Y my_arr = np.array([ [.20, .54, .26], # <0 [.22, .54, .24], # 1 [.19, .56, .25], # 2 [.19, .58, .23], # 3 [.17, .62, .21] ]) # 4+ if a user enters a y (example,...

Interpolation in PHP

I'm looking for a function in PHP for interpolating a set of irregular placed data (x,y,z) to a gridded data set for using it in ContourPlot function in JPGraph. I've developed a function based on simple Inverse distance weighting, but it is too slow. I need to use another method like "Modified Shepard's Method" or any other possible met...

Stretching out an array

I've got a vector of samples that form a curve. Let's imagine there are 1000 points in it. If I want to stretch it to fill 1500 points, what is the simplest algorithm that gives decent results? I'm looking for something that is just a few lines of C/C++. I'll always want to increase the size of the vector, and the new vector can be a...

Writing a paint program à la MS Paint - how to interpolate between mouse move events?

I want to write a paint program in the style of MS Paint. For painting things on screen when the user moves the mouse, I have to wait for mouse move events and draw on the screen whenever I receive one. Apparently, mose move events are not sent very often, so I have to interpolate the mouse movement by drawing a line between the current...

Math: Ease In, ease Out a displacement using Hermite curve with time constraint

Hi, I'm trying to write a method that interpolates from 0 to x (position of an object in one dimension) over time using acceleration at the beginning and deceleration at the end (ease out / ease in) with the only constraints that the total time is provided, as well as the duration of the acceleration and deceleration. the motion should r...

Interpolating angles

I am trying to do a rotation of a game object by setting a start and end point and X frames to do the movement. Then interpolate start and end angle to get it done. It works well, but I am trying to do the shortest possible route as an option (as opposed to "do the longest route"). In most cases it works, but if the rotation goes above...

Akima interpolation of an array of doubles

Assuming I have an array of doubles, what's a good algorithm to sample this series using Akima interpolation? I'm too stupid to translate that mathematical description into code. // values is an array of doubles // idx is the index of the left-hand value for the current interpolation // t is the normalized parameter between values[idx] ...

Surface Reconstruction from Contours with Quick Rescaling

I'm looking to construct a 3-D surface of a part of the brain based on 2-D contours from cross-sectional slices from multiple angles. Once I get this shape, I want to "fit" it to another set of contours via rescaling. I'm aspiring to do this in the context of an MCMC analysis, so it would be very nice if I could easily compute the volum...

Problem with 2D interpolation in SciPy, non-rectangular grid

Hi all, I've been trying to use scipy.interpolate.bisplrep() and scipy.interpolate.interp2d() to find interpolants for data on my (218x135) 2D spherical-polar grid. To these I pass 2D arrays, X and Y, of the Cartesian positions of my grid nodes. I keep getting errors like the following (for linear interp. with interp2d): "Warning: ...

matlab - plot 2D rectangle with interpolated color

I want to plot a 2d rect (using the rectangle function is good enough for my needs), but with a linearly interpolated color, i.e at the bottom it should be red, at the top blue, and between the two there should be the linear interpolation of the two colors. How can I do this? ...

Bicubic-ly Resize Images with Javascript

Is there a way to resize the actual image using JavaScript? I'm not talking about modifying the DOM to get the browser to resize the image. I actually want to resize the image's pixel data and then display that. Basically my problem is: Firefox completely fails at downsizing images with delicate features because it only has Nearest N...

Fast but anti-aliased resizing in Java

Hi! I need an algorithm for resizing images in J2ME. The faster and lighter, the better. But nearest-neighbour is not an option as I need anti-aliasing. Something like Hermite interpolation sounds OK. I am not an expert there, so no need to laugh. Note: I won't need colour unpacking as the data will be grayscale. Thanks a lot! ...

MATLAB: Using interpolation to replace missing values (NaN)

Hello, I have cell array each containing a sequence of values as a row vector. The sequences contain some missing values represented by NaN. I would like to replace all NaNs using some sort of interpolation method, how can I can do this in MATLAB? I am also open to other suggestions on how to deal with these missing values. Consider t...

Resize images client-side to thumbnails results in jaggy and ugly pictures

Im trying to use thumbnails on the fly so I won't have to have both thumbs and actual images. I had em done with PHP (with the excellent imagecopyresampled function) which worked great. Now I'm looking to do something similar without PHP and I'm curious about the alternatives. Having the browsers do the rendering doesn't seem to be a go...

Interpolation search on strings

For those of you not familiar with interpolation search, it is method to search for a value in a sorted array that is potentially faster than binary search. You look at the first and last element and (assuming that the contents of the array are uniformly distributed) linearly interpolate to predict the location. For example: we have an ...