Last active
August 29, 2015 14:13
-
-
Save larsberg/32dd5562fb0474bb7bd3 to your computer and use it in GitHub Desktop.
Revisions
-
larsberg revised this gist
Feb 7, 2015 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ // 1D gaussian kernel // pretty much ripped from here: http://www.apileofgrains.nl/blur-filters-c/ vector<float> gaussianKernel( int radius, float weight = 1.) { int mem_amount = (radius*2)+1; -
larsberg created this gist
Jan 14, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ // 1D gaussian kernel // modified from here: http://www.apileofgrains.nl/blur-filters-c/ vector<float> gaussianKernel( int radius, float weight = 1.) { int mem_amount = (radius*2)+1; vector<float> kernel( (radius*2) + 1 ); float twoRadiusSquaredRecip = 1.0 / (2.0 * radius * radius); float sqrtTwoPiTimesRadiusRecip = 1.0 / (sqrt(2.0 * PI) * radius); // Create Gaussian Kernel int r = -radius; float sum = 0, x, v; for (int i = 0; i < kernel.size(); i++) { v = sqrtTwoPiTimesRadiusRecip * exp(-pow(r * weight, 2) * twoRadiusSquaredRecip); kernel[i] = v; sum+=v; r++; } // normalize for (auto& k: kernel) k /= sum; return kernel; }