This commit is contained in:
Simon Gruber
2023-11-20 07:43:12 +01:00
parent fd26cf45e0
commit d8008e4f05
25 changed files with 1063 additions and 131 deletions
@@ -17,4 +17,11 @@ public class AutoThresholdProcessor : SingleImageProcessor
image.AutoThreshold(_method);
return image;
}
#region Overrides of Object
/// <inheritdoc />
public override string ToString() => $"{nameof(AutoThresholdProcessor)}({_method})";
#endregion
}
@@ -5,16 +5,27 @@ namespace Ocr.Tesseract.Screenshots.Threshold;
public class ThresholdAdaptiveProcessor : SingleImageProcessor
{
private readonly int _width;
private readonly int _height;
private readonly int _width;
private readonly int _height;
public ThresholdAdaptiveProcessor(int width, int height)
{
_width = width;
_height = height;
}
public ThresholdAdaptiveProcessor(int size) : this(size, size)
{
}
/// <inheritdoc />
protected override MagickImage Process(MagickImage image) => image
.ThresholdAdaptive(_width, _height);
}
public ThresholdAdaptiveProcessor(int width, int height)
{
_width = width;
_height = height;
}
/// <inheritdoc />
protected override MagickImage Process(MagickImage image) => image
.ThresholdAdaptive(_width, _height);
#region Overrides of Object
/// <inheritdoc />
public override string ToString() => $"{nameof(ThresholdAdaptiveProcessor)}({_width:D2}_{_height:D2})";
#endregion
}
@@ -4,18 +4,25 @@ namespace Ocr.Tesseract.Screenshots.Threshold;
public class ThresholdProcessor : SingleImageProcessor
{
private readonly Percentage _percentage;
private readonly Percentage _percentage;
public ThresholdProcessor(int percentage)
{
_percentage = new Percentage(percentage);
}
public ThresholdProcessor(int percentage)
{
_percentage = new Percentage(percentage);
}
/// <inheritdoc />
protected override MagickImage Process(MagickImage image)
{
image.Threshold(_percentage);
return image;
}
}
/// <inheritdoc />
protected override MagickImage Process(MagickImage image)
{
image.Threshold(_percentage);
return image;
}
#region Overrides of Object
/// <inheritdoc />
public override string ToString() => $"{nameof(ThresholdProcessor)}({_percentage})";
#endregion
}
+2
View File
@@ -1,4 +1,5 @@
using ImageMagick;
using System.Text.Json.Serialization;
namespace Ocr.Tesseract.Models;
@@ -26,6 +27,7 @@ public struct ScanResult
/// <summary>
/// Value referenced by <see cref="Word"/>
/// </summary>
[JsonIgnore]
public MagickImage Image { get; set; }