From 77daf5e639f8f6b95cf79acc7c787e7328198861 Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Thu, 27 Oct 2011 10:36:44 -0400 Subject: [PATCH] Correct blur radius after Box-Muller --- cuburn/code/variations.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cuburn/code/variations.py b/cuburn/code/variations.py index d14b483..401c1cb 100644 --- a/cuburn/code/variations.py +++ b/cuburn/code/variations.py @@ -332,7 +332,10 @@ var(34, 'blur', """ var(35, 'gaussian_blur', """ float ang = mwc_next_01(rctx) * 2.0f * M_PI; - float r = w * sqrtf(-2.0f * log2f(mwc_next_01(rctx)) / M_LOG2E); + // constant factor here is stdev correction for converting to Box-Muller; + // np.std(np.sum(np.random.random((1<<30, 4)), axis=1) - 2) + // TODO: maybe derive it analytically + float r = w * 0.57736 * sqrtf(-2.0f * log2f(mwc_next_01(rctx)) / M_LOG2E); ox += r * cosf(ang); oy += r * sinf(ang); """) @@ -342,7 +345,7 @@ var(36, 'radial_blur', """ float spinvar = sinf(blur_angle); float zoomvar = cosf(blur_angle); - float r = w * sqrtf(-2.0f * log2f(mwc_next_01(rctx)) / M_LOG2E); + float r = w * 0.57736 * sqrtf(-2.0f * log2f(mwc_next_01(rctx)) / M_LOG2E); float ra = sqrtf(tx*tx + ty*ty); float tmpa = atan2f(ty, tx) + spinvar * r; float rz = zoomvar * r - 1.0f;