interpolation

setting up a CUDA 2D “unsigned char” texture for linear interpolation

倾然丶 夕夏残阳落幕 提交于 2019-12-03 03:49:00
I have a linear array of unsigned chars representing a 2D array. I would like to place it into a CUDA 2D texture and perform (floating point) linear interpolation on it, i.e., have the texture call fetch the 4 nearest unsigned char neighbors, internally convert them to float, interpolate between them, and return the resulting floating point value. I am having some difficulty setting up the texture and binding it to a texture reference. I have been through the CUDA reference manual & appendices, but I'm just not having any luck. Below is runnable code to set up and bind 1) a floating point

Interpolation in I18n array

半世苍凉 提交于 2019-12-03 03:44:44
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 follows: ["Line 1", "Line 2", "Line 3 has a variable named variable", "Line 4"] However, the output is: [

Smoothing a 2-D figure

﹥>﹥吖頭↗ 提交于 2019-12-03 03:31:41
I have a number of vaguely rectangular 2D figures that need to be smoothed. A simplified example: fig, ax1 = plt.subplots(1,1, figsize=(3,3)) xs1 = [-0.25, -0.625, -0.125, -1.25, -1.125, -1.25, 0.875, 1.0, 1.0, 0.5, 1.0, 0.625, -0.25] ys1 = [1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 1.875, 1.75, 1.625, 1.5, 1.375, 1.25, 1.25] ax1.plot(xs1, ys1) ax1.set_ylim(0.5,2.5) ax1.set_xlim(-2,2) ; I have tried scipy.interpolate.RectBivariateSpline but that apparently wants data at all the points (e.g. for a heat map), and scipy.interpolate.interp1d but that, reasonably enough, wants to generate a 1d smoothed

analogy to scipy.interpolate.griddata?

≡放荡痞女 提交于 2019-12-03 03:23:25
I want to interpolate a given 3D point cloud: I had a look at scipy.interpolate.griddata and the result is exactly what I need, but as I understand, I need to input "griddata" which means something like x = [[0,0,0],[1,1,1],[2,2,2]] . But my given 3D point cloud don't has this grid-look - The x,y-values don't behave like a grid - anyway there is only a single z-value for each x,y-value.* So is there an alternative to scipy.interpolate.griddata for my not-in-a-grid-point-cloud? *edit: "no grid look" means my input looks like this: x = [0,4,17] y = [-7,25,116] z = [50,112,47] This is a function

Find minimum distance from point to complicated curve

混江龙づ霸主 提交于 2019-12-03 03:18:02
问题 I have a complicated curve defined as a set of points in a table like so (the full table is here): # x y 1.0577 12.0914 1.0501 11.9946 1.0465 11.9338 ... If I plot this table with the commands: plt.plot(x_data, y_data, c='b',lw=1.) plt.scatter(x_data, y_data, marker='o', color='k', s=10, lw=0.2) I get the following: where I've added the red points and segments manually. What I need is a way to calculate those segments for each of those points, that is: a way to find the minimum distance from

Fade a color to white (increasing brightness)

五迷三道 提交于 2019-12-03 00:29:19
I want to make a text box in .NET "glow" yellow, and then "fade" to white (basically, by incrementally increasing the brightness). I think Stackoverflow does this after you've posted an answer. I know that increasing brightness is not all that simple (it's not just uniformly increasing/decreasing RGB), but I'm not sure how to do this. Perfect color accuracy is not important for this. I am using C#, although VB examples would be just fine, too. Edit: This is for Winforms. This may be more than you need, here's the code for the class I use: public class ControlColorAnimator { private const int

C++ plane interpolation from a set of points

百般思念 提交于 2019-12-03 00:05:22
问题 I am programming in C++ with the PCL, point cloud, library. My problem is: computing the variance of some of the points but only with respect to the perpendicular axis with respect to the plane. I will explain myself: So what I am doing is dividing the point cloud into segments by surface smoothness (with region growing segmentation). For each segment I would like to have a measurement of how accurate the surface is, and I thougth the best way was to compute the plane that best fits the

Python pandas time series interpolation and regularization

陌路散爱 提交于 2019-12-02 22:56:03
I am using Python Pandas for the first time. I have 5-min lag traffic data in csv format: ... 2015-01-04 08:29:05,271238 2015-01-04 08:34:05,329285 2015-01-04 08:39:05,-1 2015-01-04 08:44:05,260260 2015-01-04 08:49:05,263711 ... There are several issues: for some timestamps there's missing data (-1) missing entries (also 2/3 consecutive hours) the frequency of the observations is not exactly 5 minutes, but actually loses some seconds once in a while I would like to obtain a regular time series, so with entries every (exactly) 5 minutes (and no missing valus). I have successfully interpolated

Java 2D weighted data interpolation

我只是一个虾纸丫 提交于 2019-12-02 20:45:55
I'm trying to find some Java lib, code example (or a starting point) to help me figure out how can I interpolate a list of 2d points with a weight to generate a interpolation with level curves. Googling I figure out that there is several algorithms available to do this, and i found some explanations with interesting content. The first algorithm that I want to try is the Inverse Distance Weighted interpolation. But with all this information i have some basic doubts: To generate one picture like the picture below, i have to do a pixel matrix (with weight), interpolate the data, group pixels

How to perform cubic spline interpolation in python?

China☆狼群 提交于 2019-12-02 18:25:35
I have two lists to describe the function y(x): x = [0,1,2,3,4,5] y = [12,14,22,39,58,77] I would like to perform cubic spline interpolation so that given some value u in the domain of x, e.g. u = 1.25 I can find y(u). I found this in SciPy but I am not sure how to use it. youngmit Short answer: from scipy import interpolate def f(x): x_points = [ 0, 1, 2, 3, 4, 5] y_points = [12,14,22,39,58,77] tck = interpolate.splrep(x_points, y_points) return interpolate.splev(x, tck) print(f(1.25)) Long answer: scipy separates the steps involved in spline interpolation into two operations, most likely for