Browse Source

only applying clipping once, effect applying it multiple times is neglectable

pull/673/head
popow 8 years ago
parent
commit
f84b03b5f1
  1. 12
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistEqualizationProcessor.cs

12
src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistEqualizationProcessor.cs

@ -169,8 +169,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
/// </summary> /// </summary>
/// <param name="histogram">The histogram to apply the clipping.</param> /// <param name="histogram">The histogram to apply the clipping.</param>
/// <param name="clipLimit">The histogram clip limit. Histogram bins which exceed this limit, will be capped at this value.</param> /// <param name="clipLimit">The histogram clip limit. Histogram bins which exceed this limit, will be capped at this value.</param>
/// <returns>The number of pixels redistributed to all other bins.</returns> private void ClipHistogram(Span<int> histogram, int clipLimit)
private int ClipHistogram(Span<int> histogram, int clipLimit)
{ {
int sumOverClip = 0; int sumOverClip = 0;
for (int i = 0; i < histogram.Length; i++) for (int i = 0; i < histogram.Length; i++)
@ -187,15 +186,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization
{ {
histogram[i] += addToEachBin; histogram[i] += addToEachBin;
} }
// The redistribution will push some bins over the clip limit again.
// Re-Applying the clipping until this effect no longer occurs.
while (addToEachBin > 1)
{
addToEachBin = this.ClipHistogram(histogram, clipLimit);
}
return addToEachBin;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save