interpolation

inverse distance weighting interpolation

╄→гoц情女王★ 提交于 2019-12-21 22:53:47
问题 I would like to compute a weight as reciprocal of a distance for something like inverse distance weighting interpolation. double wgt = 0, wgt_tmp, result = 0; for (int i = 0; i < num; i++) { wgt_tmp = 1.0/dist[i]; wgt += wgt_tmp; result += wgt_tmp * values[i]; } results /= wgt; However the distance can be 0 and I need to make the weight suitable for computation. If there is only one distance dist[i] is 0 , I would like its corresponding value values[i] to be dominant . If there are several

Interpolate function using Apache Commons Math

人走茶凉 提交于 2019-12-21 19:41:20
问题 I'm trying to implement some Interpolation functions to plot some values where the X value = Date.seconds and the Y value = double. I'v been researching using the Apache Commons Math lib to achieve this and I've found a method I think I might be able to use here The method I'm trying to understand: public double linearInterp(double[] x, double[] y, double xi) { // return linear interpolation of (x,y) on xi LinearInterpolator li = new LinearInterpolator(); PolynomialSplineFunction psf = li

Using Radial Basis Functions to Interpolate a Function on a Sphere

一世执手 提交于 2019-12-21 12:26:56
问题 First, a bit of background: I am using spherical harmonics as an example of a function on the surface of a sphere like the front spheres in this image: I produced one of these spheres, coloured according to the value of the harmonic function at points on its surface. I do this first for a very large number of points, so my function is very accurate. I've called this my fine sphere. Now that I have my fine sphere, I take a relatively small number of points on the sphere. These are the points I

Affine transform with interpolation

谁说我不能喝 提交于 2019-12-21 05:17:08
问题 I would like to do an affine transformation on a very low resolution bitmap and I would like to do it while preserving the maximum amount of information. My input data is a 1 bit 64-by-64 pixel image of hand written character and my output would be greyscale and higher resolution. Upon analysing the image I construct a series of affine transformations (rotation, scaling, shear, translation) what I could multiply into a single affine transformation matrix. My problem is that given the input

remove the holes in an image by average values of surrounding pixels

橙三吉。 提交于 2019-12-21 04:06:32
问题 can any one please help me in filling these black holes by values taken from neighboring non-zero pixels. thanks 回答1: There is a file on Matlab file exchange, - inpaint_nans that does exactly what you want. The author explains why and in which cases it is better than Delaunay triangulation. 回答2: One nice way to do this is to is to solve the linear heat equation. What you do is fix the "temperature" (intensity) of the pixels in the good area and let the heat flow into the bad pixels. A

Python/Scipy Interpolation (map_coordinates)

妖精的绣舞 提交于 2019-12-20 19:31:43
问题 I'm trying to do some interpolation with scipy. I've gone through many examples, but I'm not finding exactly what I want. Let's say I have some data where the row and column variable can vary from 0 to 1. The delta changes between each row and column is not always the same (see below). | 0.00 0.25 0.80 1.00 ------|---------------------------- 0.00 | 1.40 6.50 1.50 1.80 0.60 | 8.90 7.30 1.10 1.09 1.00 | 4.50 9.20 1.80 1.20 Now I want to be able to take a set of x,y points and determine the

R - Smoothing color and adding a legend to a scatterplot

泪湿孤枕 提交于 2019-12-20 15:26:10
问题 I have a scatterplot in R. Each (x,y) point is colored according to its z value. So you can think of each point as (x,y,z) , where (x,y) determines its position and z determines its color along a color gradient. I would like to add two things A legend on the right side showing the color gradient and what z values correspond to what colors I would like to smooth all the color using some type of interpolation, I assume. In other words, the entire plotting region (or at least most of it) should

Interpolation in I18n array

吃可爱长大的小学妹 提交于 2019-12-20 14:36:02
问题 I'm using arrays in a locale file to be able to generate blocks of text in various output methods (ActionMailer templates, Prawn documents, HAML templates) that are locale-specific. It works perfectly, but sometimes I want to pass variables into these I18n calls. However, this doesn't work. Say my locale file looks like this: en: my_array: - "Line 1" - "Line 2" - "Line 3 has a %{variable}" - "Line 4" I want the output of I18n.t('my_array', :variable => 'variable named variable') to be as

Linear interpolation in R

独自空忆成欢 提交于 2019-12-20 12:35:13
问题 I have a dataset of real data, for example looking like this: # Dataset 1 with known data known <- data.frame( x = c(0:6), y = c(0, 10, 20, 23, 41, 39, 61) ) plot (known$x, known$y, type="o") Now I want to get an aswer to the question "What would the Y value for 0.3 be, if all intermediate datapoints of the original dataset, are on a straight line between the surrounding measured values?" # X values of points to interpolate from known data aim <- c(0.3, 0.7, 2.3, 3.3, 4.3, 5.6, 5.9) If you

GLSL shader: Interpolate between more than two textures

本秂侑毒 提交于 2019-12-20 10:56:03
问题 I've implemented a heightmap in OpenGL. For now it is just a sine/cosine curved terrain. At the moment I am interpolating between the white "ice" and the darker "stone" texture. This is done like this: color = mix(texture2D(ice_layer_tex, texcoord), texture2D(stone_layer_tex, texcoord), (vertex.y + amplitude) / (amplitude * 2)) The result: It works fine, but what could I do if I want to add more textures, for example a grass texture, so that the interpolation order is "ice, stone, grass"? I