diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs
index 51cbcdf28..3e33b62a6 100644
--- a/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/Convolution2DFilter.cs
@@ -23,7 +23,7 @@ namespace ImageProcessorCore.Processors
///
/// The horizontal gradient operator.
/// The vertical gradient operator.
- public Convolution2DFilter(float[,] kernelX, float[,] kernelY)
+ public Convolution2DFilter(float[][] kernelX, float[][] kernelY)
{
this.KernelX = kernelX;
this.KernelY = kernelY;
@@ -32,22 +32,20 @@ namespace ImageProcessorCore.Processors
///
/// Gets the horizontal gradient operator.
///
- public float[,] KernelX { get; }
+ public float[][] KernelX { get; }
///
/// Gets the vertical gradient operator.
///
- public float[,] KernelY { get; }
+ public float[][] KernelY { get; }
///
public override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
{
- float[,] kernelX = this.KernelX;
- float[,] kernelY = this.KernelY;
- int kernelYHeight = kernelY.GetLength(0);
- int kernelYWidth = kernelY.GetLength(1);
- int kernelXHeight = kernelX.GetLength(0);
- int kernelXWidth = kernelX.GetLength(1);
+ int kernelYHeight = KernelY.Length;
+ int kernelYWidth = KernelY[0].Length;
+ int kernelXHeight = KernelX.Length;
+ int kernelXWidth = KernelX[0].Length;
int radiusY = kernelYHeight >> 1;
int radiusX = kernelXWidth >> 1;
@@ -100,16 +98,16 @@ namespace ImageProcessorCore.Processors
if (fy < kernelXHeight)
{
- rX += kernelX[fy, fx] * r;
- gX += kernelX[fy, fx] * g;
- bX += kernelX[fy, fx] * b;
+ rX += KernelX[fy][fx] * r;
+ gX += KernelX[fy][fx] * g;
+ bX += KernelX[fy][fx] * b;
}
if (fx < kernelYWidth)
{
- rY += kernelY[fy, fx] * r;
- gY += kernelY[fy, fx] * g;
- bY += kernelY[fy, fx] * b;
+ rY += KernelY[fy][fx] * r;
+ gY += KernelY[fy][fx] * g;
+ bY += KernelY[fy][fx] * b;
}
}
}
diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs
index d39bcaba6..b22832232 100644
--- a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/EdgeDetector2DFilter.cs
@@ -18,12 +18,12 @@ namespace ImageProcessorCore.Processors
///
/// Gets the horizontal gradient operator.
///
- public abstract float[,] KernelX { get; }
+ public abstract float[][] KernelX { get; }
///
/// Gets the vertical gradient operator.
///
- public abstract float[,] KernelY { get; }
+ public abstract float[][] KernelY { get; }
///
public bool Grayscale { get; set; }
diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs
index a7d31a607..1b91615d6 100644
--- a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs
@@ -15,20 +15,24 @@ namespace ImageProcessorCore.Processors
where TColor : IPackedVector
where TPacked : struct
{
- ///
- public override float[,] KernelX => new float[,]
+ private static readonly float[][] kernelX = new float[3][]
{
- { 6, 0, -6 },
- { 0, 0, 0 },
- { -6, 0, 6 }
+ new float[] { 6, 0, -6 },
+ new float[] { 0, 0, 0 },
+ new float[] { -6, 0, 6 }
};
- ///
- public override float[,] KernelY => new float[,]
+ private static readonly float[][] kernelY = new float[3][]
{
- { -6, 0, 6 },
- { 0, 0, 0 },
- { 6, 0, -6 }
+ new float[] { -6, 0, 6 },
+ new float[] { 0, 0, 0 },
+ new float[] { 6, 0, -6 }
};
+
+ ///
+ public override float[][] KernelX => kernelX;
+
+ ///
+ public override float[][] KernelY => kernelY;
}
}
diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/PrewittProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/PrewittProcessor.cs
index 897ba212e..17e73e7b9 100644
--- a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/PrewittProcessor.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/PrewittProcessor.cs
@@ -15,20 +15,24 @@ namespace ImageProcessorCore.Processors
where TColor : IPackedVector
where TPacked : struct
{
- ///
- public override float[,] KernelX => new float[,]
+ private static readonly float[][] kernelX = new float[3][]
{
- { -1, 0, 1 },
- { -1, 0, 1 },
- { -1, 0, 1 }
+ new float[] { -1, 0, 1 },
+ new float[] { -1, 0, 1 },
+ new float[] { -1, 0, 1 }
};
- ///
- public override float[,] KernelY => new float[,]
+ private static readonly float[][] kernelY = new float[3][]
{
- { 1, 1, 1 },
- { 0, 0, 0 },
- { -1, -1, -1 }
+ new float[] { 1, 1, 1 },
+ new float[] { 0, 0, 0 },
+ new float[] { -1, -1, -1 }
};
+
+ ///
+ public override float[][] KernelX => kernelX;
+
+ ///
+ public override float[][] KernelY => kernelY;
}
}
\ No newline at end of file
diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs
index 69c5abe34..6167e54bc 100644
--- a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs
@@ -15,18 +15,22 @@ namespace ImageProcessorCore.Processors
where TColor : IPackedVector
where TPacked : struct
{
- ///
- public override float[,] KernelX => new float[,]
+ private static readonly float[][] kernelX = new float[2][]
{
- { 1, 0 },
- { 0, -1 }
+ new float[] { 1, 0 },
+ new float[] { 0, -1 }
};
- ///
- public override float[,] KernelY => new float[,]
+ private static readonly float[][] kernelY = new float[2][]
{
- { 0, 1 },
- { -1, 0 }
+ new float[] { 0, 1 },
+ new float[] { -1, 0 }
};
+
+ ///
+ public override float[][] KernelX => kernelX;
+
+ ///
+ public override float[][] KernelY => kernelY;
}
}
diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/ScharrProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/ScharrProcessor.cs
index f860d7cfb..cbae93c40 100644
--- a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/ScharrProcessor.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/ScharrProcessor.cs
@@ -15,20 +15,24 @@ namespace ImageProcessorCore.Processors
where TColor : IPackedVector
where TPacked : struct
{
- ///
- public override float[,] KernelX => new float[,]
+ private static readonly float[][] kernelX = new float[3][]
{
- { -3, 0, 3 },
- { -10, 0, 10 },
- { -3, 0, 3 }
+ new float[] { -3, 0, 3 },
+ new float[] { -10, 0, 10 },
+ new float[] { -3, 0, 3 }
};
- ///
- public override float[,] KernelY => new float[,]
+ private static readonly float[][] kernelY = new float[3][]
{
- { 3, 10, 3 },
- { 0, 0, 0 },
- { -3, -10, -3 }
+ new float[] { 3, 10, 3 },
+ new float[] { 0, 0, 0 },
+ new float[] { -3, -10, -3 }
};
+
+ ///
+ public override float[][] KernelX => kernelX;
+
+ ///
+ public override float[][] KernelY => kernelY;
}
}
\ No newline at end of file
diff --git a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/SobelProcessor.cs b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/SobelProcessor.cs
index d7f269178..4e657cb82 100644
--- a/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/SobelProcessor.cs
+++ b/src/ImageProcessorCore/Samplers/Processors/Convolution/EdgeDetection/SobelProcessor.cs
@@ -15,20 +15,24 @@ namespace ImageProcessorCore.Processors
where TColor : IPackedVector
where TPacked : struct
{
- ///
- public override float[,] KernelX => new float[,]
+ private static readonly float[][] kernelX = new float[3][]
{
- { -1, 0, 1 },
- { -2, 0, 2 },
- { -1, 0, 1 }
+ new float[] { -1, 0, 1 },
+ new float[] { -2, 0, 2 },
+ new float[] { -1, 0, 1 }
};
- ///
- public override float[,] KernelY => new float[,]
+ private static readonly float[][] kernelY = new float[3][]
{
- { -1, -2, -1 },
- { 0, 0, 0 },
- { 1, 2, 1 }
+ new float[] { -1, -2, -1 },
+ new float[] { 0, 0, 0 },
+ new float[] { 1, 2, 1 }
};
+
+ ///
+ public override float[][] KernelX => kernelX;
+
+ ///
+ public override float[][] KernelY => kernelY;
}
}