Browse Source

Missed an end of line by accident :p

pull/725/head
Simanto Rahman 8 years ago
parent
commit
8978bc3474
  1. 92
      src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor.cs

92
src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor.cs

@ -77,81 +77,81 @@ namespace SixLabors.ImageSharp.Processing.Processors
workingnRectangle, workingnRectangle,
configuration, configuration,
rows => rows =>
{
ulong sum;
for (int i = rows.Min; i < rows.Max; i++)
{ {
using (IMemoryOwner<Rgb24> tmpPixels = configuration.MemoryAllocator.Allocate<Rgb24>(width, AllocationOptions.None)) ulong sum;
{
Span<Rgb24> span = tmpPixels.GetSpan();
this.pixelOpInstance.ToRgb24(source.GetPixelRowSpan(i), span);
sum = 0; for (int i = rows.Min; i < rows.Max; i++)
{
for (int j = startX; j < endX; j++) using (IMemoryOwner<Rgb24> tmpPixels = configuration.MemoryAllocator.Allocate<Rgb24>(width, AllocationOptions.None))
{ {
ref Rgb24 rgb = ref span[(width * j) + i]; Span<Rgb24> span = tmpPixels.GetSpan();
this.pixelOpInstance.ToRgb24(source.GetPixelRowSpan(i), span);
sum += (ulong)(rgb.B + rgb.G + rgb.B); sum = 0;
if (i != 0) for (int j = startX; j < endX; j++)
{ {
intImage[i, j] = intImage[i - 1, j] + sum; ref Rgb24 rgb = ref span[(width * j) + i];
}
else sum += (ulong)(rgb.B + rgb.G + rgb.B);
{
intImage[i, j] = sum; if (i != 0)
{
intImage[i, j] = intImage[i - 1, j] + sum;
}
else
{
intImage[i, j] = sum;
}
} }
} }
} }
} }
}
); );
ParallelHelper.IterateRows( ParallelHelper.IterateRows(
workingnRectangle, workingnRectangle,
configuration, configuration,
rows => rows =>
{ {
ushort x1, x2, y1, y2; ushort x1, x2, y1, y2;
uint count; uint count;
long sum; long sum;
for (int i = rows.Min; i < rows.Max; i++) for (int i = rows.Min; i < rows.Max; i++)
{
using (IMemoryOwner<Rgb24> tmpPixes = configuration.MemoryAllocator.Allocate<Rgb24>(width))
{ {
Span<Rgb24> span = tmpPixes.GetSpan(); using (IMemoryOwner<Rgb24> tmpPixes = configuration.MemoryAllocator.Allocate<Rgb24>(width))
this.pixelOpInstance.ToRgb24(source.GetPixelRowSpan(i), span);
for (int j = startX; j < endX; j++)
{ {
ref Rgb24 rgb = ref span[(width * j) + 1]; Span<Rgb24> span = tmpPixes.GetSpan();
this.pixelOpInstance.ToRgb24(source.GetPixelRowSpan(i), span);
x1 = (ushort)Math.Max(i - clusterSize + 1, 0); for (int j = startX; j < endX; j++)
x2 = (ushort)Math.Min(i + clusterSize + 1, endY - 1); {
y1 = (ushort)Math.Max(j - clusterSize + 1, 0); ref Rgb24 rgb = ref span[(width * j) + 1];
y2 = (ushort)Math.Min(j + clusterSize + 1, endX - 1);
count = (uint)((x2 - x1) * (y2 - y1)); x1 = (ushort)Math.Max(i - clusterSize + 1, 0);
x2 = (ushort)Math.Min(i + clusterSize + 1, endY - 1);
y1 = (ushort)Math.Max(j - clusterSize + 1, 0);
y2 = (ushort)Math.Min(j + clusterSize + 1, endX - 1);
sum = (long)(intImage[x2, y2] - intImage[x1, y2] - intImage[x2, y1] + intImage[x1, y1]) count = (uint)((x2 - x1) * (y2 - y1));
if ((rgb.R + rgb.G + rgb.B) * count < sum * threshold) sum = (long)(intImage[x2, y2] - intImage[x1, y2] - intImage[x2, y1] + intImage[x1, y1]);
{
rgb = this.Lower; if ((rgb.R + rgb.G + rgb.B) * count < sum * threshold)
} {
else rgb = this.Lower;
{ }
rgb = this.Upper; else
{
rgb = this.Upper;
}
} }
} }
} }
} }
}
); );
} }
} }

Loading…
Cancel
Save