interpolation

resampling, interpolating matrix

强颜欢笑 提交于 2019-11-29 06:38:17
I'm trying to interpolate some data for the purpose of plotting. For instance, given N data points, I'd like to be able to generate a "smooth" plot, made up of 10*N or so interpolated data points. My approach is to generate an N-by-10*N matrix and compute the inner product the original vector and the matrix I generated, yielding a 1-by-10*N vector. I've already worked out the math I'd like to use for the interpolation, but my code is pretty slow. I'm pretty new to Python, so I'm hopeful that some of the experts here can give me some ideas of ways I can try to speed up my code. I think part of

Create array in loop from number of arguments

不问归期 提交于 2019-11-29 05:44:14
问题 #!/bin/bash COUNTER=$# until [ $COUNTER -eq 0 ]; do args[$COUNTER]=\$$COUNTER let COUNTER-=1 done echo ${args[@]} When i run this, I get the following results user@host:~/sandbox# ./script.sh first second third $1 $2 $3 and i'm expecting it to echo out what $1, $2, and $3 are not a text value of "$1" I'm trying to write a script in bash that will create an array that is the size of the number of arguments I give it. I'm expecting user@host:~/sandbox# ./script.sh alpha bravo charlie alpha

Cubic Spline Program

假如想象 提交于 2019-11-29 05:03:52
问题 I'm trying to write a cubic spline interpolation program. I have written the program but, the graph is not coming out correctly. The spline uses natural boundary conditions(second dervative at start/end node are 0). The code is in Matlab and is shown below, clear all %Function to Interpolate k = 10; %Number of Support Nodes-1 xs(1) = -1; for j = 1:k xs(j+1) = -1 +2*j/k; %Support Nodes(Equidistant) end; fs = 1./(25.*xs.^2+1); %Support Ordinates x = [-0.99:2/(2*k):0.99]; %Places to Evaluate

opencv find concave hull

匆匆过客 提交于 2019-11-29 04:34:03
I have a set of discrete points shown in an image, like the following I want to reconstruct or up sampling (I'm not sure what's the correct way to describe it) the image, so that the result image would be like the following . It doesn't need to be exactly the same as the example image, but the main idea is to fill up the original one. I have an initial idea about how to do it. But I don't know how to do it after the first step. My idea is to first separate image using kmeans and find out the different objects. And I have successfully done it. The resulting images after kmeans are: . After

spline interpolation coefficients of a line curve in 3d space

梦想的初衷 提交于 2019-11-29 04:19:03
问题 I am new to python. I have a line curve in the 3D space defined by a set of given points. Can anyone suggest how I can use the interpolate with spline functions of the scipy package to get the spline coefficients of the curve just like the spline.coeff function in MATLAB? Thank you! EDIT: I have used the tck = interpolate.SmoothBivariateSpline(pts2[:,0], pts2[:,1], pts2[:,2]) test_pts = pts2[:,2]-tck.ev(pts2[:,0], pts2[:,1]) print test_pts but this is for surfaces apparently and not for line

Interpolate (or extrapolate) only small gaps in pandas dataframe

微笑、不失礼 提交于 2019-11-29 04:00:45
问题 I have a pandas DataFrame with time as index (1 min Freq) and several columns worth of data. Sometimes the data contains NaN. If so, I want to interpolate only if the gap is not longer than 5 Minutes. In this case this would be a maximum of 5 consecutive NaNs. The data may look like this (several test cases, which show the problems): import numpy as np import pandas as pd from datetime import datetime start = datetime(2014,2,21,14,50) data = pd.DataFrame(index=[start + timedelta(minutes=1*x)

Bilinear image interpolation / scaling - A calculation example

北慕城南 提交于 2019-11-29 02:56:44
问题 I would like to ask you about some bilinear interpolation / scaling details. Let's assume that we have this matrix: |100 | 50 | |70 | 20 | This is a 2 x 2 grayscale image. Now, I would like scale it by factor of two and my matrix looks like this: | 100 | f1 | 50 | f2 | | f3 | f4 | f5 | f6 | | 70 | f7 | 20 | f8 | so if we would like to calculate f4 , the calculation is defined as f1 = 100 + 0.5(50 - 100) = 75 f7 = 70 + 0.5(20 - 70) = 45 and now finally: f4 = 75 + 0.5(45 - 75) = 60 However, I

Three dimensional (3D) matrix interpolation in Matlab

泪湿孤枕 提交于 2019-11-29 02:45:10
I have a 3D matrix in Matlab of certain size, however I would need to interpolate it to obtain matrix of larger size. size(M) ans= 50 108 86 I need that matrix to be interpolated and finally obtain a matrix of size 100x213x140 . Any ideas of how to do it using interp3 ? Is this possible at all? I've tried Vq = interp3(M,1:100,1:213,1:140) Error using griddedInterpolant/subsref The input data has inconsistent size. Error in interp3 (line 178) Vq = F(Xq,Yq,Zq); If I use meshgrid : [X,Y,Z] = meshgrid(1:100, 1:213, 1:140); Vq =interp3(M,X,Y,Z); Matlab seems to like it, however two things happen:

How to interpolate a line between two other lines in python

做~自己de王妃 提交于 2019-11-29 00:55:15
问题 Note: I asked this question before but it was closed as a duplicate, however, I, along with several others believe it was unduely closed, I explain why in an edit in my original post. So I would like to re-ask this question here again. Does anyone know of a python library that can interpolate between two lines. For example, given the two solid lines below, I would like to produce the dashed line in the middle. In other words, I'd like to get the centreline. The input is a just two numpy

C# Linear Interpolation

谁说胖子不能爱 提交于 2019-11-29 00:07:01
I'm having issues interpolating a data file, which i have converted from .csv into an X array and Y array where X[0] corresponds to point Y[0] for example. I need to interpolate between the values to give me a smooth file at the end. I am using a Picoscope to output the function which means each line is equally spaced in time, so only using Y values, which is why I'm trying to do this in a strange way when you see my code. The kind of values it has to deal with are: X Y 0 0 2.5 0 2.5 12000 7.5 12000 7.5 3000 10 3000 10 6000 11 6625.254 12 7095.154 So where 2 Y values next to each other are the