C# kant upptäckt (1 / 7 steg)
Steg 1: Klassen filter
allmän klass FilterMatrix
{
offentliga statisk dubbel [,] Laplacian3x3
{
få
{
returnera ny dubbel []
{ { -1, -1, -1, },
{ -1, 8, -1, },
{ -1, -1, -1, }, };
}
}
offentliga statisk dubbel [,] Laplacian5x5
{
få
{
returnera ny dubbel []
{ { -1, -1, -1, -1, -1, },
{-1, -1, -1, -1, -1,},
{-1, -1, 24, -1, -1,},
{-1, -1, -1, -1, -1,},
{ -1, -1, -1, -1, -1 }, };
}
}
offentliga statisk dubbel [,] LaplacianOfGaussian
{
få
{
returnera ny dubbel []
{{0, 0, -1, 0, 0},
{0, -1, -2, -1, 0},
{-1, -2, 16, -2, -1},
{0, -1, -2, -1, 0},
{0, 0, -1, 0, 0},};
}
}
offentliga statisk dubbel [,] Gaussian3x3
{
få
{
returnera ny dubbel []
{ { 1, 2, 1, },
{2, 4, 2,},
{ 1, 2, 1, }, };
}
}
offentliga statisk dubbel [,] Gaussian5x5Type1
{
få
{
returnera ny dubbel []
{{2, 04, 05, 04, 2},
{4 09, 12, 09, 4},
{5, 12, 15, 12, 5},
{4 09, 12, 09, 4},
{2, 04, 05, 04, 2},};
}
}
offentliga statisk dubbel [,] Gaussian5x5Type2
{
få
{
returnera ny dubbel []
{{1, 4, 6, 4, 1},
{4, 16, 24, 16, 4},
{6, 24, 36, 24, 6},
{4, 16, 24, 16, 4},
{1, 4, 6, 4, 1},};
}
}
offentliga statisk dubbel [,] Sobel3x3Horizontal
{
få
{
returnera ny dubbel []
{ { -1, 0, 1, },
{-2, 0, 2,},
{ -1, 0, 1, }, };
}
}
offentliga statisk dubbel [,] Sobel3x3Vertical
{
få
{
returnera ny dubbel []
{ { 1, 2, 1, },
{0, 0, 0,},
{ -1, -2, -1, }, };
}
}
offentliga statisk dubbel [,] Prewitt3x3Horizontal
{
få
{
returnera ny dubbel []
{ { -1, 0, 1, },
{-1, 0, 1,},
{ -1, 0, 1, }, };
}
}
offentliga statisk dubbel [,] Prewitt3x3Vertical
{
få
{
returnera ny dubbel []
{ { 1, 1, 1, },
{0, 0, 0,},
{ -1, -1, -1, }, };
}
}
offentliga statisk dubbel [,] Kirsch3x3Horizontal
{
få
{
returnera ny dubbel []
{ { 5, 5, 5, },
{ -3, 0, -3, },
{ -3, -3, -3, }, };
}
}
offentliga statisk dubbel [,] Kirsch3x3Vertical
{
få
{
returnera ny dubbel []
{ { 5, -3, -3, },
{5, 0 -3,},
{ 5, -3, -3, }, };
}
}
}
Filter-klassen
public void filter (sträng xfilter, sträng yfilter)
{
dubbel [,] xFilterMatrix;
dubbel [,] yFilterMatrix;
Switch (xfilter)
{
fallet "Laplacian3x3":
xFilterMatrix = FilterMatrix.Laplacian3x3;
bryta;
fallet "Laplacian5x5":
xFilterMatrix = FilterMatrix.Laplacian5x5;
bryta;
fallet "LaplacianOfGaussian":
xFilterMatrix = FilterMatrix.LaplacianOfGaussian;
bryta;
fallet "Gaussian3x3":
xFilterMatrix = FilterMatrix.Gaussian3x3;
bryta;
fallet "Gaussian5x5Type1":
xFilterMatrix = FilterMatrix.Gaussian5x5Type1;
bryta;
fallet "Gaussian5x5Type2":
xFilterMatrix = FilterMatrix.Gaussian5x5Type2;
bryta;
fallet "Sobel3x3Horizontal":
xFilterMatrix = FilterMatrix.Sobel3x3Horizontal;
bryta;
fallet "Sobel3x3Vertical":
xFilterMatrix = FilterMatrix.Sobel3x3Vertical;
bryta;
fallet "Prewitt3x3Horizontal":
xFilterMatrix = FilterMatrix.Prewitt3x3Horizontal;
bryta;
fallet "Prewitt3x3Vertical":
xFilterMatrix = FilterMatrix.Prewitt3x3Vertical;
bryta;
fallet "Kirsch3x3Horizontal":
xFilterMatrix = FilterMatrix.Kirsch3x3Horizontal;
bryta;
fallet "Kirsch3x3Vertical":
xFilterMatrix = FilterMatrix.Kirsch3x3Vertical;
bryta;
standard:
xFilterMatrix = FilterMatrix.Laplacian3x3;
bryta;
}
växel (yfilter)
{
fallet "Laplacian3x3":
yFilterMatrix = FilterMatrix.Laplacian3x3;
bryta;
fallet "Laplacian5x5":
yFilterMatrix = FilterMatrix.Laplacian5x5;
bryta;
fallet "LaplacianOfGaussian":
yFilterMatrix = FilterMatrix.LaplacianOfGaussian;
bryta;
fallet "Gaussian3x3":
yFilterMatrix = FilterMatrix.Gaussian3x3;
bryta;
fallet "Gaussian5x5Type1":
yFilterMatrix = FilterMatrix.Gaussian5x5Type1;
bryta;
fallet "Gaussian5x5Type2":
yFilterMatrix = FilterMatrix.Gaussian5x5Type2;
bryta;
fallet "Sobel3x3Horizontal":
yFilterMatrix = FilterMatrix.Sobel3x3Horizontal;
bryta;
fallet "Sobel3x3Vertical":
yFilterMatrix = FilterMatrix.Sobel3x3Vertical;
bryta;
fallet "Prewitt3x3Horizontal":
yFilterMatrix = FilterMatrix.Prewitt3x3Horizontal;
bryta;
fallet "Prewitt3x3Vertical":
yFilterMatrix = FilterMatrix.Prewitt3x3Vertical;
bryta;
fallet "Kirsch3x3Horizontal":
yFilterMatrix = FilterMatrix.Kirsch3x3Horizontal;
bryta;
fallet "Kirsch3x3Vertical":
yFilterMatrix = FilterMatrix.Kirsch3x3Vertical;
bryta;
standard:
yFilterMatrix = FilterMatrix.Laplacian3x3;
bryta;
}