-
-
Save Theverat/e5f82e70c07806316f4c84a916f7d021 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float *luminance = new float[width * height]; | |
float *blurredLuminance = new float[width * height]; | |
float *tmpBuffer = new float[width * height]; | |
for (int i = 0; i < pixelsCount; ++i) { | |
luminance[i] = Spectrum(img + i * 3).Y(); | |
blurredLuminance[i] = luminance[i]; | |
} | |
const float weight = 1.f; | |
GaussianBlur3x3FilterPlugin::ApplyBlurFilter<float>(width, height, | |
blurredLuminance, tmpBuffer, weight, 1.f, weight); | |
for (int i = 0; i < pixelsCount; ++i) { | |
// The heart of the algorithm | |
const float diff = fabsf(logf(blurredLuminance[i]) - logf(luminance[i])); | |
diffVector[i] = diff; | |
maxError = Max(maxError, diff); | |
if (diff > threshold) ++todoPixelsCount; | |
} | |
delete[] luminance; | |
delete[] blurredLuminance; | |
GaussianBlur3x3FilterPlugin::ApplyBlurFilter<float>(width, height, | |
&diffVector[0], tmpBuffer, weight, 1.f, weight); | |
delete[] tmpBuffer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment