if (noiseFilterSize > 1) {
if (colorFunc == ColorFunc.NULL) {
pFilteredPnt.clear();
for (int i = 0; i < noiseFilterSize; i++) {
for (int j = 0; j < noiseFilterSize; j++) {
AbstractRasterPoint point = getRasterPoint(pX + j, pY + i);
int pIdx = (int) point.getCount();
if (pIdx > 0) {
double logScale;
if (pIdx < precalcLogArray.length) {
logScale = precalcLogArray[pIdx];
}
else {
logScale = (k1 * log10(1.0 + point.getCount() * motionBlurScl * k2)) / (flame.getWhiteLevel() * point.getCount() * motionBlurScl);
}
pFilteredPnt.red += filter[i][j] * logScale * point.getRed();
pFilteredPnt.green += filter[i][j] * logScale * point.getGreen();
pFilteredPnt.blue += filter[i][j] * logScale * point.getBlue();
pFilteredPnt.intensity += filter[i][j] * logScale * point.getCount() * flame.getWhiteLevel();
}
}
}
}
else {
pFilteredPnt.clear();
double rawR = 0.0, rawG = 0.0, rawB = 0.0;
double pCount = 0.0, avgLogScale = 0.0;
for (int i = 0; i < noiseFilterSize; i++) {
for (int j = 0; j < noiseFilterSize; j++) {
AbstractRasterPoint point = getRasterPoint(pX + j, pY + i);
int pIdx = (int) point.getCount();
if (pIdx > 0) {
double logScale;
if (pIdx < precalcLogArray.length) {
logScale = precalcLogArray[pIdx];
}
else {
logScale = (k1 * log10(1.0 + point.getCount() * motionBlurScl * k2)) / (flame.getWhiteLevel() * point.getCount() * motionBlurScl);
}
rawR += filter[i][j] * point.getRed();
rawG += filter[i][j] * point.getGreen();
rawB += filter[i][j] * point.getBlue();
double lPCount = filter[i][j] * point.getCount();
avgLogScale += filter[i][j] * logScale;
pCount += lPCount;
pFilteredPnt.intensity += logScale * lPCount * flame.getWhiteLevel();
}
}
}
final double scale = ChannelMixerCurves.FILTER_SCALE;
rawR = rawR * scale / pCount;
rawG = rawG * scale / pCount;
rawB = rawB * scale / pCount;
pFilteredPnt.red = avgLogScale * colorFunc.mapRGBToR(rawR, rawG, rawB) * pCount / scale;
pFilteredPnt.green = avgLogScale * colorFunc.mapRGBToG(rawR, rawG, rawB) * pCount / scale;
pFilteredPnt.blue = avgLogScale * colorFunc.mapRGBToB(rawR, rawG, rawB) * pCount / scale;
}
}
else {
AbstractRasterPoint point = getRasterPoint(pX, pY);
double logScale;
long pCount = point.getCount();
if (pCount < precalcLogArray.length) {
logScale = precalcLogArray[(int) pCount];
}
else {
logScale = (k1 * log10(1.0 + pCount * motionBlurScl * k2)) / (flame.getWhiteLevel() * pCount * motionBlurScl);
}
if (pCount > 0) {
if (colorFunc == ColorFunc.NULL) {
pFilteredPnt.red = logScale * point.getRed();
pFilteredPnt.green = logScale * point.getGreen();
pFilteredPnt.blue = logScale * point.getBlue();
}
else {
final double scale = ChannelMixerCurves.FILTER_SCALE;
double rawR = point.getRed() * scale / pCount;
double rawG = point.getGreen() * scale / pCount;
double rawB = point.getBlue() * scale / pCount;
pFilteredPnt.red = logScale * colorFunc.mapRGBToR(rawR, rawG, rawB) * pCount / scale;
pFilteredPnt.green = logScale * colorFunc.mapRGBToG(rawR, rawG, rawB) * pCount / scale;
pFilteredPnt.blue = logScale * colorFunc.mapRGBToB(rawR, rawG, rawB) * pCount / scale;
}
pFilteredPnt.intensity = logScale * point.getCount() * flame.getWhiteLevel();
}
else {
pFilteredPnt.red = pFilteredPnt.green = pFilteredPnt.blue = 0;
pFilteredPnt.intensity = 0;
}