Questions tagged [python]

Python is a high-level interpreted general programming language. Python has popular numerical and scientific libraries/packages, most notably numpy and scipy. The scipy.signal package is a powerful signal processing software collection. This tag covers the use of numpy, scipy, and other Python packages often used for SP computations.

Filter by
Sorted by
Tagged with
34
votes
7answers
19k views

Finding squares in Image

I need to find the squares in an image using OpenCV (no problem in matlab or any other, generally what i expect are some ideas). Consider the test image below : I need to find those coloured squares ...
27
votes
3answers
30k views

Picking the correct filter for accelerometer data

I am fairly new to DSP, and have done some research on possible filters for smoothing accelerometer data in python. An example of the type of data Ill be experiencing can be seen in the following ...
23
votes
1answer
48k views

low pass filter and FFT for beginners with Python

I am new to signal processing and especially to FFT, hence I am not sure if I am doing the correct thing here and I am a bit confused with the result. I have a discrete real function (measurement ...
22
votes
2answers
29k views

Applying filter in scipy.signal: Use lfilter or filtfilt?

I saw in a SO thread a suggestion to use filtfilt which performs backwards/forwards filtering instead of lfilter. What is the ...
21
votes
2answers
19k views

Improving spectrogram resolution in Python?

I'm using the specgram() function in matplotlib to generate spectrograms of speech wave files in Python, but the output is ...
19
votes
3answers
10k views

What's wrong with this code for tomographic reconstruction by the Fourier method?

I've been playing around with tomographic reconstruction algorithms recently. I already have nice working implementations of FBP, ART, a SIRT/SART-like iterative scheme and even using straight linear ...
16
votes
4answers
9k views

Counting the number of groups of 1s in a boolean map of numpy.array

I am right now dealing with some image processing in Python via PIL (Python Image Library). My main aim is counting the number of colored cells in an immunohistochemistry image. I know that there are ...
16
votes
5answers
48k views

How to write lowpass filter for sampled signal in Python?

I have some signal that sampled each 1 ns (1e-9 sec) and have, let say, 1e4 points. I need to filter high frequencies from this signal. Let say I need to filter frequencies higher than 10 MHz. I want ...
16
votes
1answer
20k views

What is the phase and magnitude response of white noise?

I would like to create white noise in the frequency domain, and then transform it to the time domain using python. To understand the problem, I simply generated white noise in the time domain, and ...
14
votes
4answers
14k views

Scipy - Audio Processing

I am looking for good tools for Audio signal processing. e.g Speech & music analysis, automatic language identification, etc. Does the Scipy library provide functions for audio processing? Does ...
12
votes
3answers
4k views

Fail to separate sound signals by FastICA on real-world recording

I have written a program to perform FastICA on a stereo WAV file using the code on Python MDP FastICA Example With the audio examples I get very good results. Then I try to do real world recording ...
12
votes
3answers
991 views

Image processing coding

I was wondering which is the best language for image processing? I know MATLAB has a good library and user community for it. I havent checked it out, its there for python as well. What is the most ...
12
votes
3answers
4k views

STFT and DWT (Wavelets)

STFT can be successfully used on sound data (with a .wav soundfile for example) in order to do some frequency-domain modifications (example : noise removal). With ...
10
votes
1answer
12k views

Discrete Wavelet Transform - Visualizing Relation between Decomposed Detail Coefficients and Signal

I'm trying to directly visualize the relation between discrete wavelet transform (DWT) detail coefficients and the original signal/its reconstruction. The goal is to show their relation in an ...
9
votes
3answers
2k views

Implementation of Wikipedia Equation for the DFT

I was writing a simple fourier transform implementation and looked at the DFT equation on wikipedia for reference, when I noticed that I was doing something differently, and after thinking about it ...
9
votes
1answer
341 views

Recognizing data clustered into shapes

I am working on a project in Python to detect and classify some bird song, and I have found myself in a position where I need to convert a wave file into frequency vs. time data. This hasn't been too ...
8
votes
3answers
5k views

Is it correct to subtract a low-pass filtered signal from the original signal and use the result as a “high-pass”?

I am having a hard time trying to find documentation to implement band-pass or high-pass filter with python/scipy/numpy. I can easily create and apply a low-pass filter, though, so I ask: Would it ...
8
votes
2answers
7k views

How can I detect buttons in a GUI of an app with pattern detection using python?

I will explain taking as example the GUI of the Calculator app in windows. Given this Calculator application open and focused, I need to find a way of detecting all the buttons.I can only use non-...
7
votes
2answers
4k views

Filtering - multiplication in frequency domain

I am trying to create a simple low pass filter, but I have got what I consider a surprising result when looking at the frequency response of a simple Butterworth filter. I have copied much of the ...
7
votes
1answer
2k views

Failed to implement Goertzel algorithm in Python

After some questioning on stackoverflow, I tried to implement a Goertzel algorithm in Python. But it doesn't work : https://gist.github.com/4128537 ...
7
votes
2answers
10k views

Filtering a digital signal online in real-time using python

I am currently trying to apply a bandpass filter to a signal in real-time. There are samples coming in with a constant sampling rate and i would like to calculate the corresponding bandpass filtered ...
7
votes
1answer
2k views

Is it possible to hack camera calibration without having access to the camera?

Many times we have a stream of video to process without access to camera. Having access to camera matrix would be beneficial for various processing techniques. Is it possible to hack camera ...
7
votes
1answer
1k views

Removing a sinusoidal artifact from a set of movie frames

I am doing some post-hoc analysis of a dataset consisting of a series of movie frames that are contaminated by a strongly periodic artifact. I would like to remove this artifact from my frames. For ...
6
votes
2answers
9k views

How to locally quantify the 'sharpness' of an image?

I am trying to quantify how much sharpness (or acutance) is in a picture which has some bokeh (out of focus background). I am using the Python scikit image for that. Here is my naive approach: ...
6
votes
4answers
7k views

Differences between Python and MATLAB filtfilt function

I'm trying to port some MATLAB code to Python and am running into some strange behaviour. I am implementing a 5th order Butterworth bandpass filter. The sampling rate is 30 Hz. Running MATLAB R2012b, ...
6
votes
2answers
17k views

Continuous Wavelet Transform with Scipy.signal: what is parameter “widths” in cwt() function? How do time-frequency?

I search to display a time-frequency signal with an original discrete temporal signal (sampling step = 0.001sec). I use Python and the library Scipy.signal. I use the function ...
6
votes
1answer
268 views

Morphing between two FFTs

I'm a musician and I'm making a script that takes a wave file and snaps each of its frequencies from the fourier transforms to the nearest musical harmonic. Thanks to help from another question I ...
6
votes
1answer
1k views

Haar series approximation of a function?

I'm trying to code the Haar wavelet approximation of a function. I'm a complete newbie. Edit Below is a pseudo-code of my algorithm for $f: [0,10] \to \mathbb R$, $f(x)=x$. I picked it here and ...
6
votes
1answer
1k views

Issues with the smoothing operator in coherence estimation using the complex Morlet (Gabor) wavelet

The goal I wish to compute the coherence estimate using the continuous wavelet transform (CWT) of a real-valued signal with the complex Morlet (a.k.a. Gabor) wavelet. I compute the cwt of the signal ...
5
votes
3answers
13k views

Beginner Attempting FFT Signal Filtering With Numpy

I've tried looking around for information on this, but I'm really out of my league here. I'm a guy who likes to fool around with Python, and I wanted to make a program that would filter an audio file. ...
5
votes
5answers
1k views

Does windowing affect Parseval's theorem?

I have computed Fourier transform from ecg data.It does obey Parseval's theorem, relation $$\sum_{n=0}^{N-1} \Big| x[n] \Big|^2 = \frac{1}{N} \sum_{k=0}^{N-1} \Big| X[k] \Big|^2$$ is fulfiled. ...
5
votes
3answers
28k views

Apply Low pass Butterworth filter in Python

I want to use a low pass Butterworth filter on my data but on applying the filter I don't get the intended signal. Here is the dummy code: Signal A: ...
5
votes
2answers
3k views

Simulating analog filter using convolution or converting with fft

My task is simple; I want to simulate analog low-pass filtering of an input signal, using Python. Note that the input signal is an array of values, not an analytical function. My first question is if ...
5
votes
1answer
7k views

Working backwards from PSD to possible signal

I have been trying to reconstruct a random signal from its PSD and am running into trouble. I know that many different signals in the time or spatial domains can result in the same PSD-- I am ...
5
votes
1answer
4k views

Signal filtering using Python

I'm trying to create an application using python that is capable of recording an audio signal and detecting short glitches in the signal. For example, I could be recording a 1000Hz sine wave and ...
5
votes
2answers
4k views

Complex impulse response functions?

I think I must have misunderstood something regarding the relation between impulse and frequency responses. I have calculated the Impulse Response Function, IRF, from the Frequency Response Function,...
5
votes
2answers
415 views

how can I calculate pitch deviation in a large collection of audio files?

I am making a software model of an existing digital synthesiser and I have made audio recordings of single notes with particular parameter settings. I made a program in C++ which sends a MIDI sysex ...
5
votes
1answer
5k views

Applying a filter on an audio signal with Python

Let's say I have a filter described by its transfer function: $$ H(\omega) = \frac{1}{1 + j\frac{\omega}{\omega_0}} $$ And I want to apply this filter to an audio signal (a .wav file) using Python. ...
5
votes
2answers
4k views

Opencv color segmentation of traffic signs: HSV ranges

I am working on a project to detect and recognize signs in images from the LISA Traffic Sign Dataset. Since the images are very noisy (in regard to background) I am trying to segment the signs based ...
5
votes
1answer
4k views

Demodulating FSK audio in Python

I am trying to write a Python script that can demodulate an FSK modulated audio file and return the data encoded in the audio. The data being transmitted is GPS NMEA strings which are embedded as the ...
4
votes
3answers
14k views

python; audio; detecting silence in audio signal

I have real-time audio application written in python, and I have question about detecting silence. What's the most efficient way to distinguish silence from non-silence, in an input audio signal? By ...
4
votes
1answer
16k views

How should I select window size and overlap?

I'm new to DSP and I have a wav file with a number of different frequencies playing at different volumes. I'd like to plot the power of the 350Hz frequency signal at each point in time. The source is ...
4
votes
2answers
1k views

Iterative Hard Thresholding (Python Implementation) [closed]

I'm trying to implement the Iterative Hard Thresholding recovery algorithm for compressive sensing in python. It is a very simple algorithm, given $ \mathbf{y}( = \mathbf{A}\mathbf{x}), \mathbf{A}$, ...
4
votes
4answers
20k views

Peak Signal to Noise Ratio (PSNR) in Python for an Image

How do I calculate the maximum signal to noise ratio (PSNR) in Python? Is there any library that can calculate PSNR for Image?
4
votes
2answers
10k views

Negative values of the FFT

I try to describe a simple signal in the frequency domain with the use of FFT function: ...
4
votes
3answers
5k views

Looking for Fastest 2D Convolution in Python on a CPU

Convolutions are essential components of many algorithms in neural networks, image processing, computer vision ... but these are also a bottleneck in terms of computations... In the ...
4
votes
1answer
13k views

What do I do with the result of an FFT?

So I am working on a project using digital signal processing, which I am not familiar with at all, and a lot of this is all new to me. I am using SciPy\NumPy to play around with code to understand the ...
4
votes
1answer
8k views

Taking audio frequency and picking out peaks (Peak Detection)

So I have a unique challenge. I want to take an audio file, and pick out the peaks in the samples and plot that onto a graph. Each point based on the amplitude/pitch(?) will be represented as either a ...
4
votes
1answer
3k views

Tracking a Sine Wave with Kalman Filter - How to Account for Offset (DC Signal)?

I am attempting to create a Kalman filter to track a sine wave (I am using a linear Kalman filter example assuming I already know the frequency of the sine wave) - the example I am using is derived on ...
4
votes
1answer
8k views

python scipy fft on numpy hanning window smears peaks

I have a signal that I have acquired from an experimental instrument, that I wish to examine in the frequency domain. I don't care about phase for this exercise, I only care about magnitude. I ...