From addad052b1c0e5dcf931864d340214cd26c5487a Mon Sep 17 00:00:00 2001 From: Erik Reckase Date: Tue, 21 Jun 2011 11:22:20 -0600 Subject: [PATCH] closes 11 - all black pixels with non-zero density were not being handled properly. --- cuburn/code/filtering.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/cuburn/code/filtering.py b/cuburn/code/filtering.py index 59435e4..c998c50 100644 --- a/cuburn/code/filtering.py +++ b/cuburn/code/filtering.py @@ -5,7 +5,7 @@ class ColorClip(HunkOCode): def __init__(self, features): self.defs = self.defs_tmpl.substitute(features=features) - defs_tmpl = Template(""" + defs_tmpl = Template(''' __global__ void colorclip(float4 *pixbuf, float gamma, float vibrancy, float highpow, float linrange, float lingam, float3 bkgd) { @@ -14,6 +14,11 @@ void colorclip(float4 *pixbuf, float gamma, float vibrancy, float highpow, int i = blockDim.x * blockIdx.x + threadIdx.x; float4 pix = pixbuf[i]; + if (i == 58905) { + printf("pix = %f %f %f %f\\n",pix.w,pix.x,pix.y,pix.z); + } + + if (pix.w <= 0) { pixbuf[i] = make_float4(bkgd.x, bkgd.y, bkgd.z, 0); return; @@ -28,6 +33,12 @@ void colorclip(float4 *pixbuf, float gamma, float vibrancy, float highpow, } float ls = vibrancy * alpha / pix.w; + + if (i == 58905) { + printf("alpha = %f, ls = %f\\n",alpha, ls); + } + + alpha = fminf(1.0f, fmaxf(0.0f, alpha)); float maxc = fmaxf(pix.x, fmaxf(pix.y, pix.z)); @@ -50,10 +61,12 @@ void colorclip(float4 *pixbuf, float gamma, float vibrancy, float highpow, } else { float adjhlp = -highpow; if (adjhlp > 1.0f || maxa <= 1.0f) adjhlp = 1.0f; - float adj = ((1.0f - adjhlp) * newls + adjhlp * ls); - pix.x *= adj; - pix.y *= adj; - pix.z *= adj; + if (maxc > 0.0f) { + float adj = ((1.0f - adjhlp) * newls + adjhlp * ls); + pix.x *= adj; + pix.y *= adj; + pix.z *= adj; + } } pix.x += (1.0f - vibrancy) * powf(opix.x, gamma); @@ -79,7 +92,7 @@ void colorclip(float4 *pixbuf, float gamma, float vibrancy, float highpow, pixbuf[i] = pix; } -""") +''') class DensityEst(HunkOCode): """