resampling

Resample a numpy array

落爺英雄遲暮 提交于 2019-12-03 19:13:18
问题 It's easy to resample an array like a = numpy.array([1,2,3,4,5,6,7,8,9,10]) with an integer resampling factor . For instance, with a factor 2 : b = a[::2] # [1 3 5 7 9] But with a non-integer resampling factor, it doesn't work so easily : c = a[::1.5] # [1 2 3 4 5 6 7 8 9 10] => not what is needed... It should be (with linear interpolation): [1 2.5 4 5.5 7 8.5 10] or (by taking the nearest neighbour in the array) [1 3 4 6 7 9 10] How to resample a numpy array with a non-integer resampling

What is the name of this algorithm, and how does it compare to other image resampling algorithms?

不羁岁月 提交于 2019-12-03 17:03:15
问题 This algorithm has been in my mind for a long time, but I cannot find it described anywhere. It's so simple though that I can't be the only one who has thought of it. Here's how it works: You start with an image. Say, 7x7px: You need to resample it say, to 5x5px: So all you do is take the average color of each new square: This isn't the nearest-neighbor, because that takes the color of just one pixel, not fractional pixels who happen to overlay the source pixel. It's also not bilinear,

Resample a time series with the index of another time series

最后都变了- 提交于 2019-12-03 11:58:22
问题 I have 2 data frames with identical columns but different datetime indices. I want to resample one of them to use the index of the other and forward fill data from the one on any dates in the index of the other in which there wasn't data for. import pandas as pd import numpy as np from datetime import datetime as dt a_values = np.random.randn(4, 4) a_index = [dt(2012, 3, 16), dt(2012, 3, 19), dt(2012, 3, 20), dt(2012, 3, 21)] a = pd.DataFrame(data=a_values, index=a_index) b_values = np.trunc

Python Data Frame resample on micro second

前提是你 提交于 2019-12-03 10:16:27
问题 I am working with resampling data frame and it works on hours, days mins, but doesn't resample less then sec. Program just hangs even on short time span. So am I missing something? I tried 0.000001S, U etc... Nothing worked so far. my time format: 2015-08-29 19:30:47.015506 you can see varable sf represent resampling freq. grph = df.set_index('Date and Time').resample(sf, len).astype(int) How can I resample data frame on micro seconds granularity? 回答1: sf = "1U" #for one microsecond For

Library for audio resampling

此生再无相见时 提交于 2019-12-03 09:29:05
问题 In an embedded (Windows CE) C++ project, I have to resample an arbitrary sample-rate down (or up) to 44100 Hz. Is there a free and portable C/C++ library for audio resampling? 回答1: This page lists a bunch of options. Formatted exert, for the records. Please check out the above link for important details and licence information: libresample and sndfile-resample (from libsamplerate ) (in the Planet CCRMA Distribution). libsoxr , the SoX resampler library ssrc (from Shibatch) There is a project

Transparent png resizing with Python Image Library and the halo effect

怎甘沉沦 提交于 2019-12-03 08:08:04
There are a couple similar questions on SO, but none of them really helped. Basically I am trying to resize a simple png image, as seen here: http://media.spiralknights.com/wiki-images/3/3e/Equipment-Proto_Sword_icon.png (from the mmo Spiral Knights, copyright Three Rings Entertainment) I had originally implemented a utility which uses these images in php, and the resizing utility there worked perfectly well. I used the method described on the imagecopyresampled page in PHP's documentation. Honestly I can't even get it to resize better in Photoshop, but the results are almost disastrous in

What is the name of this algorithm, and how does it compare to other image resampling algorithms?

£可爱£侵袭症+ 提交于 2019-12-03 05:57:06
This algorithm has been in my mind for a long time, but I cannot find it described anywhere. It's so simple though that I can't be the only one who has thought of it. Here's how it works: You start with an image. Say, 7x7px: You need to resample it say, to 5x5px: So all you do is take the average color of each new square: This isn't the nearest-neighbor, because that takes the color of just one pixel, not fractional pixels who happen to overlay the source pixel. It's also not bilinear, bicubic, lanczos or anything else interpolating. So - what is it? It intuitively seems to me that this should

Where can I find a good read about bicubic interpolation and Lanczos resampling?

狂风中的少年 提交于 2019-12-03 05:49:28
问题 I want to implement the two above mentioned image resampling algorithms (bicubic and Lanczos) in C++. I know that there are dozens of existing implementations out there, but I still want to make my own. I want to make it partly because I want to understand how they work, and partly because I want to give them some capabilities not found in mainstream implementations (like configurable multi-CPU support and progress reporting). I tried reading Wikipedia, but the stuff is a bit too dry for me.

Resample a numpy array

与世无争的帅哥 提交于 2019-12-03 03:27:39
It's easy to resample an array like a = numpy.array([1,2,3,4,5,6,7,8,9,10]) with an integer resampling factor . For instance, with a factor 2 : b = a[::2] # [1 3 5 7 9] But with a non-integer resampling factor, it doesn't work so easily : c = a[::1.5] # [1 2 3 4 5 6 7 8 9 10] => not what is needed... It should be (with linear interpolation): [1 2.5 4 5.5 7 8.5 10] or (by taking the nearest neighbour in the array) [1 3 4 6 7 9 10] How to resample a numpy array with a non-integer resampling factor? Example of application: audio signal resampling / repitching NumPy has numpy.interp which does

Resample a time series with the index of another time series

走远了吗. 提交于 2019-12-03 02:37:50
I have 2 data frames with identical columns but different datetime indices. I want to resample one of them to use the index of the other and forward fill data from the one on any dates in the index of the other in which there wasn't data for. import pandas as pd import numpy as np from datetime import datetime as dt a_values = np.random.randn(4, 4) a_index = [dt(2012, 3, 16), dt(2012, 3, 19), dt(2012, 3, 20), dt(2012, 3, 21)] a = pd.DataFrame(data=a_values, index=a_index) b_values = np.trunc(np.random.randn(3, 4) * 1000) b_index = [dt(2012, 3, 16), dt(2012, 3, 19), dt(2012, 3, 21)] b = pd