Skip to content

Instantly share code, notes, and snippets.

@dymk
Last active December 18, 2015 21:29
Show Gist options
  • Select an option

  • Save dymk/5847769 to your computer and use it in GitHub Desktop.

Select an option

Save dymk/5847769 to your computer and use it in GitHub Desktop.
/// Maps coefficient location to a weight bucket
/// Initialized with a self executing lambda, a-la Javascript
shared float[ImageArea] WeightBins = (() {
float[ImageArea] tmp;
foreach(i; 0..ImageHeight) {
foreach(j; 0..ImageWidth) {
tmp[(i * ImageHeight) + j] = min(max(i, j), 5);
}
}
return tmp;
})();
/*
0 1 2 3 4 5 5 5 5 5
1 1 2 3 4 5 5 5 5 5
2 2 2 3 4 5 5 5 5 5
3 3 3 3 4 5 5 5 5 5
4 4 4 4 4 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment