smoothing

Is there a Python equivalent to the smooth.spline function in R

橙三吉。 提交于 2019-12-03 05:04:49
The smooth.spline function in R allows a tradeoff between roughness (as defined by the integrated square of the second derivative) and fitting the points (as defined by summing the squares of the residuals). This tradeoff is accomplished by the spar or df parameter. At one extreme you get the least squares line, and the other you get a very wiggly curve which intersects all of the data points (or the mean if you have duplicated x values with different y values) I have looked at scipy.interpolate.UnivariateSpline and other spline variants in Python, however, they seem to only tradeoff by

Gradient in noisy data, python

丶灬走出姿态 提交于 2019-12-03 04:35:23
问题 I have an energy spectrum from a cosmic ray detector. The spectrum follows an exponential curve but it will have broad (and maybe very slight) lumps in it. The data, obviously, contains an element of noise. I'm trying to smooth out the data and then plot its gradient. So far I've been using the scipy sline function to smooth it and then the np.gradient(). As you can see from the picture, the gradient function's method is to find the differences between each point, and it doesn't show the

Edge Smoothing and filling inner contours in opencv with iOS

∥☆過路亽.° 提交于 2019-12-03 04:04:26
I am trying to tan human skin with different intensity with help of opencv. I have already identified human skin and changing color tone of those pixels. But it is not smooth. Top left - original image Top right - saturation channel of original image Bottom left - Gray scale mask identifying locations of skin on original image Bottom right - result image with color tone changed of pixels located in mask. Now my problem is that, in mask image some gap is left because of variation on color tone or brightness in original image. And that is why those portion is missed in result image. Can anyone

How to smoothen a plot in MATLAB?

依然范特西╮ 提交于 2019-12-03 03:49:05
问题 I have some 9000 points that are plotted on a graph: [Full resolution] Actually, the plot is not as smooth as I wanted it to be. Is there some way I can smoothen the graph to a required degree? Or some form of thresholding so that I can selectively smoothen out the parts that is too bumpy? I am not sure but can fast-fourier-transform help? 回答1: A simple (ad hoc) way is to just take a weighted average (tunable by alpha ) at each point with its neighbors: data(2:n-1) = alpha*data(2:n-1) + (1

For Loop in R (Looking for an alternative)

穿精又带淫゛_ 提交于 2019-12-02 19:13:19
问题 The following code runs a loops but the problem is the speed; it takes several hours to finish and I am looking for an alternative so that I don´t have to wait so long. Basically what the code does the follolling calculations: 1.-It calculates the mean of the values of the 60 days. 2.-It gets the standard deviation of the values of the 60 days. 3.-It gets the Max of the values of the 60 days. 4.-It gets the Min of the values of the 60 days. 5.-Then with the previous calculations the code

Estimating rate of occurrence of an event with exponential smoothing and irregular events

天大地大妈咪最大 提交于 2019-12-02 18:23:40
Imagine that I have a set of measurements of x that are taken by many processes x 0 ... x N at times t 0 ... t N . Let's assume that at time t I want to make an estimate of the current value of x , based on the assumption that there is no long term trend I know about and that x can be predicted from an algorithm such as exponential smoothing. As we have many processes, and N can get very large, I can't store more than a few values (e.g. the previous state). One approach here would be to adapt the normal exponential smoothing algorithm. If samples are taken regularly, I would maintain an

How to smoothen a plot in MATLAB?

烂漫一生 提交于 2019-12-02 17:13:28
I have some 9000 points that are plotted on a graph: [ Full resolution ] Actually, the plot is not as smooth as I wanted it to be. Is there some way I can smoothen the graph to a required degree? Or some form of thresholding so that I can selectively smoothen out the parts that is too bumpy? I am not sure but can fast-fourier-transform help? A simple (ad hoc) way is to just take a weighted average (tunable by alpha ) at each point with its neighbors: data(2:n-1) = alpha*data(2:n-1) + (1-alpha)*0.5*(data(1:n-2)+data(3:n)) or some variation thereof. Yes, to be more sophisticated you can Fourier

filtering/removing noise

烈酒焚心 提交于 2019-12-02 14:44:57
问题 The question is simple. How do I go about removing noise from data? I have made up some x and y values along with some noise that is a gross simplification of the data I am dealing with (apart from the random noise I cannot make that the same as the noise I have to deal with). I don't really know if I need to filter or smooth. My file contains two sets of data that need to be plotted and there is experimental noise in this data, what is the best way to remove it? smoothing or filtering? I

For Loop in R (Looking for an alternative)

霸气de小男生 提交于 2019-12-02 10:27:30
The following code runs a loops but the problem is the speed; it takes several hours to finish and I am looking for an alternative so that I don´t have to wait so long. Basically what the code does the follolling calculations: 1.-It calculates the mean of the values of the 60 days. 2.-It gets the standard deviation of the values of the 60 days. 3.-It gets the Max of the values of the 60 days. 4.-It gets the Min of the values of the 60 days. 5.-Then with the previous calculations the code "smooths" the peaks up and down. 6.-Then the code simply get the means from 60, 30, 15 and 7 Days. So the

Scipy implementation of Savitzky-Golay filter

安稳与你 提交于 2019-12-02 03:49:23
问题 I was looking at the scipy cookbook implementation of the Savitzky-Golay algorithm: #!python def savitzky_golay(y, window_size, order, deriv=0, rate=1): r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter. The Savitzky-Golay filter removes high frequency noise from data. It has the advantage of preserving the original shape and features of the signal better than other types of filtering approaches, such as moving averages techniques. Parameters ---------- y : array