You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when NLM_WINDOW_RADIUS is increased, the idx counter which indices the fWeights array,
goes out of array range. see comments with //******
__shared__ floatfWeights[BLOCKDIM_X * BLOCKDIM_Y]; //****** default fWeights size is 64constint ix = blockDim.x * blockIdx.x + threadIdx.x;
constint iy = blockDim.y * blockIdx.y + threadIdx.y;
//Add half of a texel to always address exact texel centersconstfloat x = (float)ix + 0.5f;
constfloat y = (float)iy + 0.5f;
constfloat cx = blockDim.x * blockIdx.x + NLM_WINDOW_RADIUS + 0.5f;
constfloat cy = blockDim.x * blockIdx.y + NLM_WINDOW_RADIUS + 0.5f;
if (ix < imageW && iy < imageH)
{
//Find color distance from current texel to the center of NLM windowfloat weight = 0;
for (float n = -NLM_BLOCK_RADIUS; n <= NLM_BLOCK_RADIUS; n++)
for (float m = -NLM_BLOCK_RADIUS; m <= NLM_BLOCK_RADIUS; m++)
weight += vecLen(
tex2D(texImage, cx + m, cy + n),
tex2D(texImage, x + m, y + n)
);
//Geometric distance from current texel to the center of NLM windowfloat dist =
(threadIdx.x - NLM_WINDOW_RADIUS) * (threadIdx.x - NLM_WINDOW_RADIUS) +
(threadIdx.y - NLM_WINDOW_RADIUS) * (threadIdx.y - NLM_WINDOW_RADIUS);
//Derive final weight from color and geometric distance
weight = __expf(-(weight * Noise + dist * INV_NLM_WINDOW_AREA));
//Write the result to shared memoryfWeights[threadIdx.y * BLOCKDIM_X + threadIdx.x] = weight;
//Wait until all the weights are ready__syncthreads();
//Normalized counter for the NLM weight thresholdfloatfCount = 0;
//Total sum of pixel weightsfloat sumWeights = 0;
//Result accumulator
float3 clr = {0, 0, 0};
int idx = 0;
//Cycle through NLM window, surrounding (x, y) texelfor (float i = -NLM_WINDOW_RADIUS; i <= NLM_WINDOW_RADIUS + 1; i++)
for (float j = -NLM_WINDOW_RADIUS; j <= NLM_WINDOW_RADIUS + 1; j++)
{
//Load precomputed weightfloat weightIJ = fWeights[idx++]; //****** in this line , we go out of array//******if NLM_WINDOW_RADIUS is larger than 3. just increasing the fWeights array, does not solve ///****** the // ******problem//Accumulate (x + j, y + i) texel color with computed weight
float4 clrIJ = tex2D(texImage, x + j, y + i);
clr.x += clrIJ.x * weightIJ;
clr.y += clrIJ.y * weightIJ;
clr.z += clrIJ.z * weightIJ;
//Sum of weights for color normalization to [0..1] range
sumWeights += weightIJ;
//Update weight counter, if NLM weight for current window texel//exceeds the weight thresholdfCount += (weightIJ > NLM_WEIGHT_THRESHOLD) ? INV_NLM_WINDOW_AREA : 0;
}
The text was updated successfully, but these errors were encountered:
when NLM_WINDOW_RADIUS is increased, the
idx
counter which indices the fWeights array,goes out of array range. see comments with //******
The text was updated successfully, but these errors were encountered: