gaussian

Generating 3D Gaussian distribution in Python

大兔子大兔子 提交于 2019-12-07 04:51:32
问题 I want to generate a Gaussian distribution in Python with the x and y dimensions denoting position and the z dimension denoting the magnitude of a certain quantity. The distribution has a maximum value of 2e6 and a standard deviation sigma=0.025. In MATLAB I can do this with: x1 = linspace(-1,1,30); x2 = linspace(-1,1,30); mu = [0,0]; Sigma = [.025,.025]; [X1,X2] = meshgrid(x1,x2); F = mvnpdf([X1(:) X2(:)],mu,Sigma); F = 314159.153*reshape(F,length(x2),length(x1)); surf(x1,x2,F); In Python,

Gaussian blur that handles alpha transparency

回眸只為那壹抹淺笑 提交于 2019-12-06 17:44:29
I have been trying to implement an algorithm in C# for a gaussian blur that takes care of transparency. I tried the following two implementations, and each seems to give me different type of results. But neither takes into account the alpha channel. http://code.google.com/p/imagelibrary/downloads/detail?name=ImageLibrary-source-1_2_4.zip&can=2&q= http://www.smokycogs.com/blog/image-processing-in-c-sharp-smoothing-using-convolution/ My test image has a simple circle on a transparent background PNG. Could somebody point me in the right direction to get the gaussian blur to work with images that

Creating a Python Histogram without Pylab

主宰稳场 提交于 2019-12-06 15:23:09
问题 I have to generate a list of random numbers with a gaussian distribution (I'm able to do this) and then take those numbers and plot them in a histogram. My problem is that I'm supposed to do this without using the built-in histogram function within pylab (or any other package for that matter) and I'm at a complete loss. I've been looking on-line and I haven't found anything that explains how I would go about this, does any of you know what I could do? Thanks in advance. 回答1: Let's assume you

Fast Gaussian blur on unsigned char image- ARM Neon Intrinsics- iOS Dev

╄→尐↘猪︶ㄣ 提交于 2019-12-06 13:37:33
问题 Can someone tell me a fast function to find the gaussian blur of an image using a 5x5 mask. I need it for iOS app dev. I am working directly on the memory of the image defined as unsigned char *image_sqr_Baseaaddr = (unsigned char *) malloc(noOfPixels); for (row = 2; row < H-2; row++) { for (col = 2; col < W-2; col++) { newPixel = 0; for (rowOffset=-2; rowOffset<=2; rowOffset++) { for (colOffset=-2; colOffset<=2; colOffset++) { rowTotal = row + rowOffset; colTotal = col + colOffset; iOffset =

How to add and remove noise from an image

点点圈 提交于 2019-12-06 13:14:46
问题 I want to add gaussian noise to a 256x256 greyscale image and then remove it. I tried doing using the following code but all I get is an image which has noise alone. Is it possible to completely remove the noise from the image? And if not to what extent can gaussian noise be reduced? P =0; %mean Q =0.01; %variance R = imnoise(L,'gaussian',P,Q); %L-image subplot(2,1,1); imshow(R); title('Gaussian Noise'); U = conv2(double(R), ones(3)/9, 'same'); U1=uint8(U); subplot(2,1,2); imshow(U1); title(

How can I fit multiple Gaussian curved to mass spectrometry data in Python?

孤者浪人 提交于 2019-12-06 12:47:51
I would like to fit multiple Gaussian curves to Mass spectrometry data in Python. Right now I'm fitting the data one Gaussian at a time -- literally one range at a time. Is there a more streamlined way to do this? Is there a way I can run the data through a loop to plot a Gaussian at each peak? I'm guessing there's gotta be a better way, but I've combed through the internet. My graph for two Gaussians is shown below. My example data can be found at: http://txt.do/dooxv And here's my current code: import numpy as np import matplotlib.pyplot as plt import scipy.optimize as opt from scipy

Generating a Smooth Random Trend (Random Walk) in JavaScript

天涯浪子 提交于 2019-12-06 12:20:07
问题 I am looking for a JavaScript implementation of a random walk/random trend algorithm. I need something that will stick with a trend (so, just plain random deltas are out) while still staying within some specified boundaries. I tried writing something off the top of my head by choosing numbers based on a weighted average (the weight was calculated using the Gaussian function) and ended up with a slightly smoother line (not good enough). I then took a less direct approach and tried searching on

Scikit-learn's Pipeline: Error with multilabel classification. A sparse matrix was passed

99封情书 提交于 2019-12-06 11:47:47
问题 I am implementing different classifiers using different machine learning algorithms. I'm sorting text files, and do as follows: classifier = Pipeline([ ('vectorizer', CountVectorizer ()), ('TFIDF', TfidfTransformer ()), ('clf', OneVsRestClassifier (GaussianNB()))]) classifier.fit(X_train,Y) predicted = classifier.predict(X_test) When I use the algorithm GaussianNB the following error occurs: TypeError: A sparse matrix was passed, but dense data is required. Use X.toarray () to convert to a

Gaussian Filter without using ConvolveOp

自闭症网瘾萝莉.ら 提交于 2019-12-06 09:53:18
I am trying to create a guassian filter without using ConvolveOp. I am having a lot of problems trying to get this to work, i have gotten a grey scale filter to work, but for this one i am having problems finding the location of a pixels 8 neighbors, so i can apply the filter. here is what i have so far. Is this the right way to approach getting each of the pixels? public class Gaussian implements Filter { public void filter(PixelImage pi) { Pixel[][] data = pi.getData(); Pixel[][] original = data; int kernel_rows = 3; int kernel_cols = 3; // define kernel here (double loop), these are the 1

Separating gaussian components of a curve using python

送分小仙女□ 提交于 2019-12-06 08:32:29
I am trying to deblend the emission lines of low resolution spectrum in order to get the gaussian components. This plot represents the kind of data I am using: After searching a bit, the only option I found was the application of the gauest function from the kmpfit package ( http://www.astro.rug.nl/software/kapteyn/kmpfittutorial.html#gauest ). I have copied their example but I cannot make it work. I wonder if anyone could please offer me any alternative to do this or how to correct my code: import numpy as np import matplotlib.pyplot as plt from scipy import optimize def CurveData(): x = np