Last active
November 19, 2017 22:28
-
-
Save LionRoar/e6aa4effa7a89920be30a6eb888d80b3 to your computer and use it in GitHub Desktop.
boxesForGaussianBlur
This file contains 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
private int[] boxesForGaussian(double sigma, int n) { | |
double wIdeal = Math.Sqrt((12 * sigma * sigma / n) + 1); | |
double wl = Math.Floor(wIdeal); | |
if (wl % 2 == 0) wl--; | |
double wu = wl + 2; | |
double mIdeal = (12 * sigma * sigma– n * wl * wl– 4 * n * wl– 3 * n) / (-4 * wl– 4); | |
double m = Math.Round(mIdeal); | |
int[] sizes = new int[n]; | |
for (int i = 0; i < n; i++) { | |
if (i < m) { | |
sizes[i] = (int) wl; | |
} else { | |
sizes[i] = (int) wu; | |
} | |
} | |
return sizes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment