Skip to content

Commit 39ed542

Browse files
Merge branch 'master' into ImageIntegral
2 parents 8147ec3 + aca46ac commit 39ed542

File tree

8 files changed

+78
-75
lines changed

8 files changed

+78
-75
lines changed

.gitattributes

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,20 @@
8383
# treat as binary
8484
###############################################################################
8585
*.basis binary
86-
*.bmp binary
87-
*.dds binary
8886
*.dll binary
8987
*.eot binary
9088
*.exe binary
91-
*.gif binary
92-
*.jpg binary
9389
*.ktx binary
9490
*.otf binary
9591
*.pbm binary
9692
*.pdf binary
97-
*.png binary
9893
*.ppt binary
9994
*.pptx binary
10095
*.pvr binary
10196
*.snk binary
102-
*.tga binary
103-
*.tif binary
104-
*.tiff binary
10597
*.ttc binary
10698
*.ttf binary
10799
*.wbmp binary
108-
*.webp binary
109100
*.woff binary
110101
*.woff2 binary
111102
*.xls binary
@@ -121,4 +112,16 @@
121112
*.pptx diff=astextplain
122113
*.rtf diff=astextplain
123114
*.svg diff=astextplain
124-
*.jpg,*.jpeg,*.bmp,*.gif,*.png,*.tif,*.tiff,*.tga,*.webp filter=lfs diff=lfs merge=lfs -text
115+
###############################################################################
116+
# Handle image files by git lfs
117+
###############################################################################
118+
*.jpg filter=lfs diff=lfs merge=lfs -text
119+
*.jpeg filter=lfs diff=lfs merge=lfs -text
120+
*.bmp filter=lfs diff=lfs merge=lfs -text
121+
*.gif filter=lfs diff=lfs merge=lfs -text
122+
*.png filter=lfs diff=lfs merge=lfs -text
123+
*.tif filter=lfs diff=lfs merge=lfs -text
124+
*.tiff filter=lfs diff=lfs merge=lfs -text
125+
*.tga filter=lfs diff=lfs merge=lfs -text
126+
*.webp filter=lfs diff=lfs merge=lfs -text
127+
*.dds filter=lfs diff=lfs merge=lfs -text

src/ImageSharp/Processing/BinaryThresholdColorComponent.cs renamed to src/ImageSharp/Processing/BinaryThresholdMode.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
namespace SixLabors.ImageSharp.Processing
55
{
66
/// <summary>
7-
/// The color component to be compared to threshold.
7+
/// Selects the value to be compared to threshold.
88
/// </summary>
9-
public enum BinaryThresholdColorComponent : int
9+
public enum BinaryThresholdMode
1010
{
1111
/// <summary>
12-
/// Luminance color component according to ITU-R Recommendation BT.709.
12+
/// Compare the color luminance (according to ITU-R Recommendation BT.709).
1313
/// </summary>
1414
Luminance = 0,
1515

1616
/// <summary>
17-
/// HSL saturation color component.
17+
/// Compare the HSL saturation of the color.
1818
/// </summary>
1919
Saturation = 1,
2020

2121
/// <summary>
22-
/// Maximum of YCbCr chroma value, i.e. Cb and Cr distance from achromatic value.
22+
/// Compare the maximum of YCbCr chroma value, i.e. Cb and Cr distance from achromatic value.
2323
/// </summary>
2424
MaxChroma = 2,
2525
}

src/ImageSharp/Processing/Extensions/Binarization/BinaryThresholdExtensions.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ public static class BinaryThresholdExtensions
1919
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
2020
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
2121
public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold)
22-
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, BinaryThresholdColorComponent.Luminance));
22+
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, BinaryThresholdMode.Luminance));
2323

2424
/// <summary>
2525
/// Applies binarization to the image splitting the pixels at the given threshold.
2626
/// </summary>
2727
/// <param name="source">The image this method extends.</param>
2828
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
29-
/// <param name="colorComponent">The color component to be compared to threshold.</param>
29+
/// <param name="mode">Selects the value to be compared to threshold.</param>
3030
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
3131
public static IImageProcessingContext BinaryThreshold(
3232
this IImageProcessingContext source,
3333
float threshold,
34-
BinaryThresholdColorComponent colorComponent)
35-
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, colorComponent));
34+
BinaryThresholdMode mode)
35+
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, mode));
3636

3737
/// <summary>
3838
/// Applies binarization to the image splitting the pixels at the given threshold with
@@ -48,24 +48,24 @@ public static IImageProcessingContext BinaryThreshold(
4848
this IImageProcessingContext source,
4949
float threshold,
5050
Rectangle rectangle)
51-
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, BinaryThresholdColorComponent.Luminance), rectangle);
51+
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, BinaryThresholdMode.Luminance), rectangle);
5252

5353
/// <summary>
5454
/// Applies binarization to the image splitting the pixels at the given threshold.
5555
/// </summary>
5656
/// <param name="source">The image this method extends.</param>
5757
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
58-
/// <param name="colorComponent">The color component to be compared to threshold.</param>
58+
/// <param name="mode">Selects the value to be compared to threshold.</param>
5959
/// <param name="rectangle">
6060
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
6161
/// </param>
6262
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
6363
public static IImageProcessingContext BinaryThreshold(
6464
this IImageProcessingContext source,
6565
float threshold,
66-
BinaryThresholdColorComponent colorComponent,
66+
BinaryThresholdMode mode,
6767
Rectangle rectangle)
68-
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, colorComponent), rectangle);
68+
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, mode), rectangle);
6969

7070
/// <summary>
7171
/// Applies binarization to the image splitting the pixels at the given threshold with
@@ -81,7 +81,7 @@ public static IImageProcessingContext BinaryThreshold(
8181
float threshold,
8282
Color upperColor,
8383
Color lowerColor)
84-
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, BinaryThresholdColorComponent.Luminance));
84+
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, BinaryThresholdMode.Luminance));
8585

8686
/// <summary>
8787
/// Applies binarization to the image splitting the pixels at the given threshold.
@@ -90,15 +90,15 @@ public static IImageProcessingContext BinaryThreshold(
9090
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
9191
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
9292
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
93-
/// <param name="colorComponent">The color component to be compared to threshold.</param>
93+
/// <param name="mode">Selects the value to be compared to threshold.</param>
9494
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
9595
public static IImageProcessingContext BinaryThreshold(
9696
this IImageProcessingContext source,
9797
float threshold,
9898
Color upperColor,
9999
Color lowerColor,
100-
BinaryThresholdColorComponent colorComponent)
101-
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, colorComponent));
100+
BinaryThresholdMode mode)
101+
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, mode));
102102

103103
/// <summary>
104104
/// Applies binarization to the image splitting the pixels at the given threshold with
@@ -118,7 +118,7 @@ public static IImageProcessingContext BinaryThreshold(
118118
Color upperColor,
119119
Color lowerColor,
120120
Rectangle rectangle)
121-
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, BinaryThresholdColorComponent.Luminance), rectangle);
121+
=> source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, BinaryThresholdMode.Luminance), rectangle);
122122

123123
/// <summary>
124124
/// Applies binarization to the image splitting the pixels at the given threshold.
@@ -127,7 +127,7 @@ public static IImageProcessingContext BinaryThreshold(
127127
/// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</param>
128128
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
129129
/// <param name="lowerColor">The color to use for pixels that are below the threshold</param>
130-
/// <param name="colorComponent">The color component to be compared to threshold.</param>
130+
/// <param name="mode">Selects the value to be compared to threshold.</param>
131131
/// <param name="rectangle">
132132
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
133133
/// </param>
@@ -137,8 +137,8 @@ public static IImageProcessingContext BinaryThreshold(
137137
float threshold,
138138
Color upperColor,
139139
Color lowerColor,
140-
BinaryThresholdColorComponent colorComponent,
140+
BinaryThresholdMode mode,
141141
Rectangle rectangle) =>
142-
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, colorComponent), rectangle);
142+
source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor, mode), rectangle);
143143
}
144144
}

src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class BinaryThresholdProcessor : IImageProcessor
1414
/// Initializes a new instance of the <see cref="BinaryThresholdProcessor"/> class.
1515
/// </summary>
1616
/// <param name="threshold">The threshold to split the image. Must be between 0 and 1.</param>
17-
/// <param name="colorComponent">The color component to be compared to threshold.</param>
18-
public BinaryThresholdProcessor(float threshold, BinaryThresholdColorComponent colorComponent)
19-
: this(threshold, Color.White, Color.Black, colorComponent)
17+
/// <param name="mode">The color component to be compared to threshold.</param>
18+
public BinaryThresholdProcessor(float threshold, BinaryThresholdMode mode)
19+
: this(threshold, Color.White, Color.Black, mode)
2020
{
2121
}
2222

@@ -26,7 +26,7 @@ public BinaryThresholdProcessor(float threshold, BinaryThresholdColorComponent c
2626
/// </summary>
2727
/// <param name="threshold">The threshold to split the image. Must be between 0 and 1.</param>
2828
public BinaryThresholdProcessor(float threshold)
29-
: this(threshold, Color.White, Color.Black, BinaryThresholdColorComponent.Luminance)
29+
: this(threshold, Color.White, Color.Black, BinaryThresholdMode.Luminance)
3030
{
3131
}
3232

@@ -36,14 +36,14 @@ public BinaryThresholdProcessor(float threshold)
3636
/// <param name="threshold">The threshold to split the image. Must be between 0 and 1.</param>
3737
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
3838
/// <param name="lowerColor">The color to use for pixels that are below the threshold.</param>
39-
/// <param name="colorComponent">The color component to be compared to threshold.</param>
40-
public BinaryThresholdProcessor(float threshold, Color upperColor, Color lowerColor, BinaryThresholdColorComponent colorComponent)
39+
/// <param name="mode">The color component to be compared to threshold.</param>
40+
public BinaryThresholdProcessor(float threshold, Color upperColor, Color lowerColor, BinaryThresholdMode mode)
4141
{
4242
Guard.MustBeBetweenOrEqualTo(threshold, 0, 1, nameof(threshold));
4343
this.Threshold = threshold;
4444
this.UpperColor = upperColor;
4545
this.LowerColor = lowerColor;
46-
this.ColorComponent = colorComponent;
46+
this.Mode = mode;
4747
}
4848

4949
/// <summary>
@@ -54,7 +54,7 @@ public BinaryThresholdProcessor(float threshold, Color upperColor, Color lowerCo
5454
/// <param name="upperColor">The color to use for pixels that are above the threshold.</param>
5555
/// <param name="lowerColor">The color to use for pixels that are below the threshold.</param>
5656
public BinaryThresholdProcessor(float threshold, Color upperColor, Color lowerColor)
57-
: this(threshold, upperColor, lowerColor, BinaryThresholdColorComponent.Luminance)
57+
: this(threshold, upperColor, lowerColor, BinaryThresholdMode.Luminance)
5858
{
5959
}
6060

@@ -73,10 +73,10 @@ public BinaryThresholdProcessor(float threshold, Color upperColor, Color lowerCo
7373
/// </summary>
7474
public Color LowerColor { get; }
7575

76-
/// <summary>
77-
/// Gets a value indicating whether to use saturation value instead of luminance.
76+
/// <summary>
77+
/// Gets the <see cref="BinaryThresholdMode"/> defining the value to be compared to threshold.
7878
/// </summary>
79-
public BinaryThresholdColorComponent ColorComponent { get; }
79+
public BinaryThresholdMode Mode { get; }
8080

8181
/// <inheritdoc />
8282
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)

src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected override void OnFrameApply(ImageFrame<TPixel> source)
4545
upper,
4646
lower,
4747
threshold,
48-
this.definition.ColorComponent,
48+
this.definition.Mode,
4949
configuration);
5050

5151
ParallelRowIterator.IterateRows<RowOperation, Rgb24>(
@@ -63,7 +63,7 @@ protected override void OnFrameApply(ImageFrame<TPixel> source)
6363
private readonly TPixel upper;
6464
private readonly TPixel lower;
6565
private readonly byte threshold;
66-
private readonly BinaryThresholdColorComponent colorComponent;
66+
private readonly BinaryThresholdMode mode;
6767
private readonly int startX;
6868
private readonly Configuration configuration;
6969

@@ -74,15 +74,15 @@ public RowOperation(
7474
TPixel upper,
7575
TPixel lower,
7676
byte threshold,
77-
BinaryThresholdColorComponent colorComponent,
77+
BinaryThresholdMode mode,
7878
Configuration configuration)
7979
{
8080
this.startX = startX;
8181
this.source = source;
8282
this.upper = upper;
8383
this.lower = lower;
8484
this.threshold = threshold;
85-
this.colorComponent = colorComponent;
85+
this.mode = mode;
8686
this.configuration = configuration;
8787
}
8888

@@ -96,9 +96,9 @@ public void Invoke(int y, Span<Rgb24> span)
9696
Span<TPixel> rowSpan = this.source.GetPixelRowSpan(y).Slice(this.startX, span.Length);
9797
PixelOperations<TPixel>.Instance.ToRgb24(this.configuration, rowSpan, span);
9898

99-
switch (this.colorComponent)
99+
switch (this.mode)
100100
{
101-
case BinaryThresholdColorComponent.Luminance:
101+
case BinaryThresholdMode.Luminance:
102102
{
103103
byte threshold = this.threshold;
104104
for (int x = 0; x < rowSpan.Length; x++)
@@ -112,7 +112,7 @@ public void Invoke(int y, Span<Rgb24> span)
112112
break;
113113
}
114114

115-
case BinaryThresholdColorComponent.Saturation:
115+
case BinaryThresholdMode.Saturation:
116116
{
117117
float threshold = this.threshold / 255F;
118118
for (int x = 0; x < rowSpan.Length; x++)
@@ -125,7 +125,7 @@ public void Invoke(int y, Span<Rgb24> span)
125125
break;
126126
}
127127

128-
case BinaryThresholdColorComponent.MaxChroma:
128+
case BinaryThresholdMode.MaxChroma:
129129
{
130130
float threshold = this.threshold / 2F;
131131
for (int x = 0; x < rowSpan.Length; x++)

0 commit comments

Comments
 (0)