|
|
@ -49,7 +49,7 @@ namespace ImageProcessor.Imaging.Filters.EdgeDetection |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Processes the given bitmap to apply the current instances <see cref="IEdgeFilter"/>.
|
|
|
/// Processes the given bitmap to apply the current instance of <see cref="IEdgeFilter"/>.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image to process.</param>
|
|
|
/// <param name="source">The image to process.</param>
|
|
|
/// <returns>A processed bitmap.</returns>
|
|
|
/// <returns>A processed bitmap.</returns>
|
|
|
@ -184,7 +184,7 @@ namespace ImageProcessor.Imaging.Filters.EdgeDetection |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Processes the given bitmap to apply the current instances <see cref="IEdgeFilter"/>.
|
|
|
/// Processes the given bitmap to apply the current instance of <see cref="I2DEdgeFilter"/>.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image to process.</param>
|
|
|
/// <param name="source">The image to process.</param>
|
|
|
/// <returns>A processed bitmap.</returns>
|
|
|
/// <returns>A processed bitmap.</returns>
|
|
|
@ -229,7 +229,10 @@ namespace ImageProcessor.Imaging.Filters.EdgeDetection |
|
|
using (FastBitmap destinationBitmap = new FastBitmap(destination)) |
|
|
using (FastBitmap destinationBitmap = new FastBitmap(destination)) |
|
|
{ |
|
|
{ |
|
|
// Loop through the pixels.
|
|
|
// Loop through the pixels.
|
|
|
for (int y = 0; y < height; y++) |
|
|
Parallel.For( |
|
|
|
|
|
0, |
|
|
|
|
|
height, |
|
|
|
|
|
y => |
|
|
{ |
|
|
{ |
|
|
for (int x = 0; x < width; x++) |
|
|
for (int x = 0; x < width; x++) |
|
|
{ |
|
|
{ |
|
|
@ -271,6 +274,7 @@ namespace ImageProcessor.Imaging.Filters.EdgeDetection |
|
|
|
|
|
|
|
|
if (offsetX < width) |
|
|
if (offsetX < width) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// ReSharper disable once AccessToDisposedClosure
|
|
|
Color currentColor = sourceBitmap.GetPixel(offsetX, offsetY); |
|
|
Color currentColor = sourceBitmap.GetPixel(offsetX, offsetY); |
|
|
double r = currentColor.R; |
|
|
double r = currentColor.R; |
|
|
double g = currentColor.G; |
|
|
double g = currentColor.G; |
|
|
@ -294,9 +298,10 @@ namespace ImageProcessor.Imaging.Filters.EdgeDetection |
|
|
byte blue = Math.Sqrt((bX * bX) + (bY * bY)).ToByte(); |
|
|
byte blue = Math.Sqrt((bX * bX) + (bY * bY)).ToByte(); |
|
|
|
|
|
|
|
|
Color newColor = Color.FromArgb(red, green, blue); |
|
|
Color newColor = Color.FromArgb(red, green, blue); |
|
|
|
|
|
// ReSharper disable once AccessToDisposedClosure
|
|
|
destinationBitmap.SetPixel(x, y, newColor); |
|
|
destinationBitmap.SetPixel(x, y, newColor); |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|