gaussian

How to add Gaussian noise to an image?

拥有回忆 提交于 2019-12-06 08:04:27
问题 How to add a certain amount of Gaussian noise to the image in python? Do I need to convert somehow the values of the image to double type or something else? Also, I have doubts about measuring the level of noise in the image. One adds it according to the dB (decibels) while other considers the variance. How it is related and how should I measure the noise level? 回答1: You can use the random_noise function in scikit-image. It goes something like this: skimage.util.random_noise(image, mode=

Smoothing Mat of float with mask

纵然是瞬间 提交于 2019-12-06 07:25:33
问题 Is there a way to apply a Gaussianblur or median smoothing filter to a mat of floating points while supplying a mask of pixels that should be ignored? could you please help me? ty. 回答1: You can do this by: Zeroing out the regions outside the mask Smooth the image and the mask Divide each pixel in the smoothed image with the value of the smoothed mask The division in step 3 compensates for the black pixels introduced by masking. This works because the smoothed mask is darkened in the same way

Computationally simple pseudo-Gaussian distribution with varying mean and standard deviation?

情到浓时终转凉″ 提交于 2019-12-06 05:49:17
This picture from Wikipedia has a nice example of the sort of functions I'd ideally like to generate: Right now I'm using the Irwin-Hall Distribution, which is more or less a polynomial approximation of the Gaussian distribution...basically, you use uniform random number generator and iterate it x times, and take the average. The more iterations, the more like a Gaussian Distribution it is. It's pretty nice; however I'd like to be able to have one where I can vary the mean. For example, let's say I wanted a number between the range 0 and 10, but around 7. Like, the mean (if I repeated this

fit (triple-) gauss to data python

让人想犯罪 __ 提交于 2019-12-05 14:13:06
The short version of my problem is the following: I have a histogram of some data (density of planets) which seems to have 3 peeks. Now I want to fit 3 gaussians to this histogram. I am expecting this outcome. I used different methods to fit my gauss: curve_fit, least square and GaussianMixture from sklearn.mixture. With Curve_fit I get a pretty good fit but it isn't good enough if you compare it to my expected outcome. With least square I get a "good fit" but my gaussians are nonsense, and with GaussianMixture I don't get anywhere, because I can't really adept the codes I've seen in Examples

Fitting partial Gaussian

流过昼夜 提交于 2019-12-05 05:35:24
I'm trying to fit a sum of gaussians using scikit-learn because the scikit-learn GaussianMixture seems much more robust than using curve_fit. Problem : It doesn't do a great job in fitting a truncated part of even a single gaussian peak: from sklearn import mixture import matplotlib.pyplot import matplotlib.mlab import numpy as np clf = mixture.GaussianMixture(n_components=1, covariance_type='full') data = np.random.randn(10000) data = [[x] for x in data] clf.fit(data) data = [item for sublist in data for item in sublist] rangeMin = int(np.floor(np.min(data))) rangeMax = int(np.ceil(np.max

Gaussian fit to a histogram data in python: Trust Region v/s Levenberg Marquardt

纵然是瞬间 提交于 2019-12-05 05:17:12
问题 My histogram plot clearly shows two peaks. But while curve-fitting it with a double gaussian, it shows just one peak. Followed almost every answer shown in stackoverflow. But failed to get the correct result. It has previously been done by my teacher in Fortran and he got two peaks. I used leastsq of python's scipy.optimize in one trial. Should I give my data also? Here is my code. binss = (max(x) - min(x))/0.05 #0.05 is my bin width n, bins, patches = plt.hist(x, binss, color = 'grey')

Gaussian blur and FFT

£可爱£侵袭症+ 提交于 2019-12-05 05:16:30
问题 I´m trying to make an implementation of Gaussian blur for a school project. I need to make both a CPU and a GPU implementation to compare performance. I am not quite sure that I understand how Gaussian blur works. So one of my questions is if I have understood it correctly? Heres what I do now: I use the equation from wikipedia http://en.wikipedia.org/wiki/Gaussian_blur to calculate the filter. For 2d I take RGB of each pixel in the image and apply the filter to it by multiplying RGB of the

Plot a contour of multivariate normal PDF of a given MVN in MATLAB?

末鹿安然 提交于 2019-12-05 03:41:58
I have a bivariate gaussian I defined as follow: I=[1 0;0 1]; mu=[0,0]; sigma=0.5*I; beta = mvnrnd(mu,sigma,100); %100x2 matrix where each column vector is a variable. now I want to plot a contour of the pdf of the above matrix. What I did: Z = mvnpdf(beta,mu,sigma); %100x1 pdf matrix Now I want to plot a contour of the bivariate gaussian beta. I know I should use the command contour but this one require Z to be a square matrix. how do I solve this? I am very confused and not sure how to plot the contour of the bivariate gaussian!! ANY HELP IS GREATLY APPRECIATED.. Thank you You need to define

GaussianMixture initialization using component parameters - sklearn

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 03:27:19
问题 I want to use sklearn.mixture.GaussianMixture to store a gaussian mixture model so that I can later use it to generate samples or a value at a sample point using score_samples method. Here is an example where the components have the following weight, mean and covariances import numpy as np weights = np.array([0.6322941277066596, 0.3677058722933399]) mu = np.array([[0.9148052872961359, 1.9792961751316835], [-1.0917396392992502, -0.9304220945910037]]) sigma = np.array([[[2.267889129267119, 0

Gaussian Blur Over Image - iOS 8

倾然丶 夕夏残阳落幕 提交于 2019-12-05 02:42:44
问题 I have a moving background image and I want to blur the bottom part of it out. I would do it with just photoshop but since the image moves, it wouldn't work very well. Here is what I mean (look at the bottom of the image) : So basically like the effect the dock has on the iPhone. I'm using iOS 8 but not Swift. 回答1: I have done a small example based on the photo you have there. My algorithm is as follows: Extract a portion of image from bottom. Apply gaussian filter to it and blur it. Then,