Skip to content
14 changes: 7 additions & 7 deletions src/ImageSharp/Color/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ namespace SixLabors.ImageSharp
private Color(byte r, byte g, byte b, byte a)
{
this.data = new Rgba64(
ImageMaths.UpscaleFrom8BitTo16Bit(r),
ImageMaths.UpscaleFrom8BitTo16Bit(g),
ImageMaths.UpscaleFrom8BitTo16Bit(b),
ImageMaths.UpscaleFrom8BitTo16Bit(a));
ColorNumerics.UpscaleFrom8BitTo16Bit(r),
ColorNumerics.UpscaleFrom8BitTo16Bit(g),
ColorNumerics.UpscaleFrom8BitTo16Bit(b),
ColorNumerics.UpscaleFrom8BitTo16Bit(a));
}

[MethodImpl(InliningOptions.ShortMethod)]
private Color(byte r, byte g, byte b)
{
this.data = new Rgba64(
ImageMaths.UpscaleFrom8BitTo16Bit(r),
ImageMaths.UpscaleFrom8BitTo16Bit(g),
ImageMaths.UpscaleFrom8BitTo16Bit(b),
ColorNumerics.UpscaleFrom8BitTo16Bit(r),
ColorNumerics.UpscaleFrom8BitTo16Bit(g),
ColorNumerics.UpscaleFrom8BitTo16Bit(b),
ushort.MaxValue);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/Cmyk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Cmyk(float c, float m, float y, float k)
[MethodImpl(InliningOptions.ShortMethod)]
public Cmyk(Vector4 vector)
{
vector = Vector4Utilities.FastClamp(vector, Min, Max);
vector = Numerics.Clamp(vector, Min, Max);
this.C = vector.X;
this.M = vector.Y;
this.Y = vector.Z;
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp/ColorSpaces/Companding/LCompanding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class LCompanding
/// <returns>The <see cref="float"/> representing the linear channel value.</returns>
[MethodImpl(InliningOptions.ShortMethod)]
public static float Expand(float channel)
=> channel <= 0.08F ? (100F * channel) / CieConstants.Kappa : ImageMaths.Pow3((channel + 0.16F) / 1.16F);
=> channel <= 0.08F ? (100F * channel) / CieConstants.Kappa : Numerics.Pow3((channel + 0.16F) / 1.16F);

/// <summary>
/// Compresses an uncompanded channel (linear) to its nonlinear equivalent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public CieXyz Convert(in CieLab input)
float fx = (a / 500F) + fy;
float fz = fy - (b / 200F);

float fx3 = ImageMaths.Pow3(fx);
float fz3 = ImageMaths.Pow3(fz);
float fx3 = Numerics.Pow3(fx);
float fz3 = Numerics.Pow3(fz);

float xr = fx3 > CieConstants.Epsilon ? fx3 : ((116F * fx) - 16F) / CieConstants.Kappa;
float yr = l > CieConstants.Kappa * CieConstants.Epsilon ? ImageMaths.Pow3((l + 16F) / 116F) : l / CieConstants.Kappa;
float yr = l > CieConstants.Kappa * CieConstants.Epsilon ? Numerics.Pow3((l + 16F) / 116F) : l / CieConstants.Kappa;
float zr = fz3 > CieConstants.Epsilon ? fz3 : ((116F * fz) - 16F) / CieConstants.Kappa;

var wxyz = new Vector3(input.WhitePoint.X, input.WhitePoint.Y, input.WhitePoint.Z);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Six Labors.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.

using System.Runtime.CompilerServices;
Expand All @@ -24,7 +24,7 @@ public CieXyz Convert(in CieLuv input)
float v0 = ComputeV0(input.WhitePoint);

float y = l > CieConstants.Kappa * CieConstants.Epsilon
? ImageMaths.Pow3((l + 16) / 116)
? Numerics.Pow3((l + 16) / 116)
: l / CieConstants.Kappa;

float a = ((52 * l / (u + (13 * l * u0))) - 1) / 3;
Expand Down Expand Up @@ -71,4 +71,4 @@ private static float ComputeU0(in CieXyz input)
private static float ComputeV0(in CieXyz input)
=> (9 * input.Y) / (input.X + (15 * input.Y) + (3 * input.Z));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public CieXyz Convert(in HunterLab input)
float ka = ComputeKa(input.WhitePoint);
float kb = ComputeKb(input.WhitePoint);

float pow = ImageMaths.Pow2(l / 100F);
float pow = Numerics.Pow2(l / 100F);
float sqrtPow = MathF.Sqrt(pow);
float y = pow * yn;

Expand Down
140 changes: 0 additions & 140 deletions src/ImageSharp/Common/Extensions/ComparableExtensions.cs

This file was deleted.

8 changes: 4 additions & 4 deletions src/ImageSharp/Common/Helpers/Buffer2DUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static void Convolve4<TPixel>(

for (int i = 0; i < kernelLength; i++)
{
int offsetY = (row + i - radiusY).Clamp(minRow, maxRow);
int offsetX = sourceOffsetColumnBase.Clamp(minColumn, maxColumn);
int offsetY = Numerics.Clamp(row + i - radiusY, minRow, maxRow);
int offsetX = Numerics.Clamp(sourceOffsetColumnBase, minColumn, maxColumn);
Span<TPixel> sourceRowSpan = sourcePixels.GetRowSpan(offsetY);
var currentColor = sourceRowSpan[offsetX].ToVector4();

Expand Down Expand Up @@ -93,13 +93,13 @@ public static void Convolve4AndAccumulatePartials(
int radiusX = kernelLength >> 1;
int sourceOffsetColumnBase = column + minColumn;

int offsetY = row.Clamp(minRow, maxRow);
int offsetY = Numerics.Clamp(row, minRow, maxRow);
ref ComplexVector4 sourceRef = ref MemoryMarshal.GetReference(sourceValues.GetRowSpan(offsetY));
ref Complex64 baseRef = ref MemoryMarshal.GetReference(kernel);

for (int x = 0; x < kernelLength; x++)
{
int offsetX = (sourceOffsetColumnBase + x - radiusX).Clamp(minColumn, maxColumn);
int offsetX = Numerics.Clamp(sourceOffsetColumnBase + x - radiusX, minColumn, maxColumn);
vector.Sum(Unsafe.Add(ref baseRef, x) * Unsafe.Add(ref sourceRef, offsetX));
}

Expand Down
Loading