|
|
@ -51,19 +51,22 @@ namespace ImageSharp.Processing.Processors |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="rowSpan">The input span of vectors</param>
|
|
|
/// <param name="rowSpan">The input span of vectors</param>
|
|
|
/// <returns>The weighted sum</returns>
|
|
|
/// <returns>The weighted sum</returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public Vector4 ComputeWeightedRowSum(BufferSpan<Vector4> rowSpan) |
|
|
public Vector4 ComputeWeightedRowSum(BufferSpan<Vector4> rowSpan) |
|
|
{ |
|
|
{ |
|
|
float* horizontalValues = this.Ptr; |
|
|
float* horizontalValues = this.Ptr; |
|
|
int left = this.Left; |
|
|
int left = this.Left; |
|
|
|
|
|
Vector4* vecPtr = (Vector4*)rowSpan.PointerAtOffset; |
|
|
|
|
|
vecPtr += left; |
|
|
|
|
|
|
|
|
// Destination color components
|
|
|
// Destination color components
|
|
|
Vector4 result = Vector4.Zero; |
|
|
Vector4 result = Vector4.Zero; |
|
|
|
|
|
|
|
|
for (int i = 0; i < this.Length; i++) |
|
|
for (int i = 0; i < this.Length; i++) |
|
|
{ |
|
|
{ |
|
|
float xw = horizontalValues[i]; |
|
|
float weight = horizontalValues[i]; |
|
|
int index = left + i; |
|
|
result += (*vecPtr) * weight; |
|
|
result += rowSpan[index] * xw; |
|
|
vecPtr++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
@ -75,19 +78,22 @@ namespace ImageSharp.Processing.Processors |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="rowSpan">The input span of vectors</param>
|
|
|
/// <param name="rowSpan">The input span of vectors</param>
|
|
|
/// <returns>The weighted sum</returns>
|
|
|
/// <returns>The weighted sum</returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public Vector4 ComputeExpandedWeightedRowSum(BufferSpan<Vector4> rowSpan) |
|
|
public Vector4 ComputeExpandedWeightedRowSum(BufferSpan<Vector4> rowSpan) |
|
|
{ |
|
|
{ |
|
|
float* horizontalValues = this.Ptr; |
|
|
float* horizontalValues = this.Ptr; |
|
|
int left = this.Left; |
|
|
int left = this.Left; |
|
|
|
|
|
Vector4* vecPtr = (Vector4*)rowSpan.PointerAtOffset; |
|
|
|
|
|
vecPtr += left; |
|
|
|
|
|
|
|
|
// Destination color components
|
|
|
// Destination color components
|
|
|
Vector4 result = Vector4.Zero; |
|
|
Vector4 result = Vector4.Zero; |
|
|
|
|
|
|
|
|
for (int i = 0; i < this.Length; i++) |
|
|
for (int i = 0; i < this.Length; i++) |
|
|
{ |
|
|
{ |
|
|
float xw = horizontalValues[i]; |
|
|
float weight = horizontalValues[i]; |
|
|
int index = left + i; |
|
|
result += (*vecPtr).Expand() * weight; |
|
|
result += rowSpan[index].Expand() * xw; |
|
|
vecPtr++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
@ -100,6 +106,7 @@ namespace ImageSharp.Processing.Processors |
|
|
/// <param name="firstPassPixels">The buffer of input vectors in row first order</param>
|
|
|
/// <param name="firstPassPixels">The buffer of input vectors in row first order</param>
|
|
|
/// <param name="x">The column position</param>
|
|
|
/// <param name="x">The column position</param>
|
|
|
/// <returns>The weighted sum</returns>
|
|
|
/// <returns>The weighted sum</returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public Vector4 ComputeWeightedColumnSum(PinnedImageBuffer<Vector4> firstPassPixels, int x) |
|
|
public Vector4 ComputeWeightedColumnSum(PinnedImageBuffer<Vector4> firstPassPixels, int x) |
|
|
{ |
|
|
{ |
|
|
float* verticalValues = this.Ptr; |
|
|
float* verticalValues = this.Ptr; |
|
|
|