|
|
@ -12,31 +12,34 @@ namespace SixLabors.ImageSharp.Processing |
|
|
public static class BinaryThresholdExtensions |
|
|
public static class BinaryThresholdExtensions |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold.
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold with
|
|
|
|
|
|
/// Luminance as the color component to be compared to threshold.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="colorComponent">The color component to be compared to threshold.</param>
|
|
|
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, BinaryThresholdColorComponent colorComponent) => |
|
|
public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold) |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, colorComponent)); |
|
|
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, BinaryThresholdColorComponent.Luminance)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold with
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold.
|
|
|
/// Luminance as color component to be compared to threshold.
|
|
|
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
|
|
|
/// <param name="colorComponent">The color component to be compared to threshold.</param>
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold) => |
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, BinaryThresholdColorComponent.Luminance)); |
|
|
this IImageProcessingContext source, |
|
|
|
|
|
float threshold, |
|
|
|
|
|
BinaryThresholdColorComponent colorComponent) |
|
|
|
|
|
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, colorComponent)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold.
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold with
|
|
|
|
|
|
/// Luminance as the color component to be compared to threshold.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="colorComponent">The color component to be compared to threshold.</param>
|
|
|
|
|
|
/// <param name="rectangle">
|
|
|
/// <param name="rectangle">
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|
|
/// </param>
|
|
|
/// </param>
|
|
|
@ -44,16 +47,15 @@ namespace SixLabors.ImageSharp.Processing |
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
this IImageProcessingContext source, |
|
|
this IImageProcessingContext source, |
|
|
float threshold, |
|
|
float threshold, |
|
|
BinaryThresholdColorComponent colorComponent, |
|
|
Rectangle rectangle) |
|
|
Rectangle rectangle) => |
|
|
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, BinaryThresholdColorComponent.Luminance), rectangle); |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, colorComponent), rectangle); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold with
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold.
|
|
|
/// Luminance as color component to be compared to threshold.
|
|
|
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
|
|
|
/// <param name="colorComponent">The color component to be compared to threshold.</param>
|
|
|
/// <param name="rectangle">
|
|
|
/// <param name="rectangle">
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|
|
/// </param>
|
|
|
/// </param>
|
|
|
@ -61,50 +63,51 @@ namespace SixLabors.ImageSharp.Processing |
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
this IImageProcessingContext source, |
|
|
this IImageProcessingContext source, |
|
|
float threshold, |
|
|
float threshold, |
|
|
Rectangle rectangle) => |
|
|
BinaryThresholdColorComponent colorComponent, |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, BinaryThresholdColorComponent.Luminance), rectangle); |
|
|
Rectangle rectangle) |
|
|
|
|
|
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, colorComponent), rectangle); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold.
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold with
|
|
|
|
|
|
/// Luminance as the color component to be compared to threshold.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
|
|
|
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
|
|
|
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
|
|
|
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
|
|
|
/// <param name="colorComponent">The color component to be compared to threshold.</param>
|
|
|
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
this IImageProcessingContext source, |
|
|
this IImageProcessingContext source, |
|
|
float threshold, |
|
|
float threshold, |
|
|
Color upperColor, |
|
|
Color upperColor, |
|
|
Color lowerColor, |
|
|
Color lowerColor) |
|
|
BinaryThresholdColorComponent colorComponent) => |
|
|
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, BinaryThresholdColorComponent.Luminance)); |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, colorComponent)); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold with
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold.
|
|
|
/// Luminance as color component to be compared to threshold.
|
|
|
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
|
|
|
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
|
|
|
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
|
|
|
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
|
|
|
|
|
|
/// <param name="colorComponent">The color component to be compared to threshold.</param>
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
public static IImageProcessingContext BinaryThreshold( |
|
|
this IImageProcessingContext source, |
|
|
this IImageProcessingContext source, |
|
|
float threshold, |
|
|
float threshold, |
|
|
Color upperColor, |
|
|
Color upperColor, |
|
|
Color lowerColor) => |
|
|
Color lowerColor, |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, BinaryThresholdColorComponent.Luminance)); |
|
|
BinaryThresholdColorComponent colorComponent) |
|
|
|
|
|
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, colorComponent)); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold.
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold with
|
|
|
|
|
|
/// Luminance as the color component to be compared to threshold.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
|
|
|
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
|
|
|
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
|
|
|
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
|
|
|
/// <param name="colorComponent">The color component to be compared to threshold.</param>
|
|
|
|
|
|
/// <param name="rectangle">
|
|
|
/// <param name="rectangle">
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|
|
/// </param>
|
|
|
/// </param>
|
|
|
@ -114,18 +117,17 @@ namespace SixLabors.ImageSharp.Processing |
|
|
float threshold, |
|
|
float threshold, |
|
|
Color upperColor, |
|
|
Color upperColor, |
|
|
Color lowerColor, |
|
|
Color lowerColor, |
|
|
BinaryThresholdColorComponent colorComponent, |
|
|
Rectangle rectangle) |
|
|
Rectangle rectangle) => |
|
|
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, BinaryThresholdColorComponent.Luminance), rectangle); |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, colorComponent), rectangle); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold with
|
|
|
/// Applies binarization to the image splitting the pixels at the given threshold.
|
|
|
/// Luminance as color component to be compared to threshold.
|
|
|
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
|
|
|
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
|
|
|
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
|
|
|
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
|
|
|
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
|
|
|
|
|
|
/// <param name="colorComponent">The color component to be compared to threshold.</param>
|
|
|
/// <param name="rectangle">
|
|
|
/// <param name="rectangle">
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|
|
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
|
|
|
/// </param>
|
|
|
/// </param>
|
|
|
@ -135,7 +137,8 @@ namespace SixLabors.ImageSharp.Processing |
|
|
float threshold, |
|
|
float threshold, |
|
|
Color upperColor, |
|
|
Color upperColor, |
|
|
Color lowerColor, |
|
|
Color lowerColor, |
|
|
|
|
|
BinaryThresholdColorComponent colorComponent, |
|
|
Rectangle rectangle) => |
|
|
Rectangle rectangle) => |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, BinaryThresholdColorComponent.Luminance), rectangle); |
|
|
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, colorComponent), rectangle); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|