Created
January 24, 2011 19:48
-
-
Save kayru/793822 to your computer and use it in GitHub Desktop.
Python script for generation of Gaussian blur weights
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def GenerateGaussianFilter(taps) : | |
weights = [] | |
sum = 0.0 | |
w = 1.0 | |
width = (taps-1)*2 | |
for i in range((width)/2+1) : | |
weights.append(w) | |
sum = sum + w | |
w = w * (width-i) / (i+1) | |
weights.reverse() | |
sum = weights[0] + (sum - weights[0])*2.0 | |
if sum > 0 : | |
for i in range(len(weights)) : | |
weights[i] = weights[i] / sum | |
return weights | |
if len(sys.argv) > 1 : | |
print GenerateGaussianFilter(int(sys.argv[1])) | |
else: | |
print "Usage: gaussian_filter_generator.py <taps>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment