void ApplyFilter(SimpleMatrix.Matrix kernel, double normilizer) { kernel /= normilizer; m_workImage = DoubleArrayImageOperations.ConvolutionFilter(m_workImage, kernel.data); RefreshWorkImage(); }
private void ПорівняльнийТестToolStripMenuItem_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(3, 3, new double[] { 1, 6, 1, 6, 36, 6, 1, 6, 1 }); double normilizer = 64; kernel /= normilizer; DateTime t1, t2; double matrixTime, formulasTime; t1 = DateTime.Now; DoubleArrayImageOperations.ConvolutionFilter(m_workImage, kernel.data); t2 = DateTime.Now; matrixTime = (t2 - t1).TotalMilliseconds; t1 = DateTime.Now; BlurEffectWithoutMatrix.Apply(m_workImage); t2 = DateTime.Now; formulasTime = (t2 - t1).TotalMilliseconds; textBox1.Text += Environment.NewLine + "Час обробки з використання матриць: " + matrixTime.ToString("0.000") + "мс" + Environment.NewLine; textBox1.Text += Environment.NewLine + "Час обробки (формула напряму): " + formulasTime.ToString("0.000") + "мс" + Environment.NewLine; }
private void S30ToolStripMenuItem1_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(3, 3, new double[] { -1, -4, -1, -4, 20, -4, -1, -4, -1 }); ApplyFilter(kernel, 36); }
//ВЧ20 private void ToolStripMenuItem2_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(3, 3, new double[] { -1, -6, -1, -6, 28, -6, -1, -6, -1 }); ApplyFilter(kernel, 64); }
private void S20ToolStripMenuItem_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(3, 3, new double[] { 1, 6, 1, 6, 36, 6, 1, 6, 1 }); ApplyFilter(kernel, 64); }
private void S40ToolStripMenuItem_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(5, 5, new double[] { 1, 76, 230, 76, 1, 76, 5776, 17480, 5776, 76, 230, 17480, 52900, 17480, 230, 76, 5776, 17480, 5776, 76, 1, 76, 230, 76, 1 }); ApplyFilter(kernel, 147456); }
//stab 2 private void ToolStripMenuItem5_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernelQuarter = new SimpleMatrix.Matrix(4, 4, new double[] { 1.24562e-08, 2.96456e-06, 1.59314e-05, -0.000149424, 2.96456e-06, 0.000705566, 0.003791678, -0.035562919, 1.59314e-05, 0.003791678, 0.020376288, -0.191113331, -0.000149424, -0.035562919, -0.191113331, 1.792490633 }); SimpleMatrix.Matrix kernel = getKernelByQuarter(kernelQuarter); ApplyFilter(kernel, 1); }
//stab 1 private void ToolStripMenuItem4_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernelQuarter = new SimpleMatrix.Matrix(4, 4, new double[] { 3.75457e-09, 8.93587e-07, 5.40282e-06, -7.38748e-05, 8.93587e-07, 0.000212674, 0.001285871, -0.01758221, 5.40282e-06, 0.001285871, 0.007774658, -0.106305883, -7.38748e-05, -0.01758221, -0.106305883, 1.45356119 }); SimpleMatrix.Matrix kernel = getKernelByQuarter(kernelQuarter); ApplyFilter(kernel, 1); }
//stab 0 private void ToolStripMenuItem3_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(5, 5, new double[] { 1, 8, -74, 8, 1, 8, 64, -592, 64, 8, -74, -592, 5476, -592, -74, 8, 64, -592, 64, 8, 1, 8, -74, 8, 1 }); ApplyFilter(kernel, 3136); }
private void S30ToolStripMenuItem2_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(5, 5, new double[] { 1, -6, 24, -6, 1, -6, 36, -144, 36, -6, 24, -144, 576, -144, 24, -6, 36, -144, 36, -6, 1, -6, 24, -6, 1 }); ApplyFilter(kernel, 196); }
private void S20ToolStripMenuItem_Click_1(object sender, EventArgs e) { SimpleMatrix.Matrix kernel = new SimpleMatrix.Matrix(5, 5, new double[] { 1, -8, 48, -8, 1, -8, 64, -384, 64, -8, 48, -384, 2304, -384, 48, -8, 64, -384, 64, -8, 1, -8, 48, -8, 1 }); ApplyFilter(kernel, 1156); }
//stab 3 private void ToolStripMenuItem6_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernelQuarter = new SimpleMatrix.Matrix(5, 5, new double[] { 1.6236e-10, 4.1165e-08, 9.20847e-07, 2.14132e-06, -1.8949e-05, 4.1165e-08, 1.0437e-05, 0.000233473, 0.000542915, -0.004804375, 9.20847e-07, 0.000233473, 0.00522272, 0.012144825, -0.107472272, 2.14132e-06, 0.000542915, 0.012144825, 0.028241375, -0.249914233, -1.8949e-05, -0.004804375, -0.107472272, -0.249914233, 2.211546853, }); SimpleMatrix.Matrix kernel = getKernelByQuarter(kernelQuarter); ApplyFilter(kernel, 1); }
//stab 4 private void ToolStripMenuItem7_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernelQuarter = new SimpleMatrix.Matrix(5, 5, new double[] { 5.26177e-10, 1.32248e-07, 2.7676e-06, 4.92362e-06, -3.85865e-05, 1.32248e-07, 3.32391e-05, 0.000695605, 0.001237494, -0.009698272, 2.7676e-06, 0.000695605, 0.014557157, 0.025897446, -0.202958992, 4.92362e-06, 0.001237494, 0.025897446, 0.046072025, -0.361067725, -3.85865e-05, -0.009698272, -0.202958992, -0.361067725, 2.829697678 }); SimpleMatrix.Matrix kernel = getKernelByQuarter(kernelQuarter); ApplyFilter(kernel, 1); }
private void S40ToolStripMenuItem2_Click(object sender, EventArgs e) { SimpleMatrix.Matrix kernelQuarter = new SimpleMatrix.Matrix(5, 5, new double[] { 0.000000451, 0.000032858, -0.000173172, 0.000543531, -0.001478877, 0.000032858, 0.002394093, -0.012617568, 0.039602551, -0.107753344, -0.000173172, -0.012617568, 0.066498257, -0.208716980, 0.567891511, 0.000543531, 0.039602551, -0.20871698, 0.655096535, -1.782431695, -0.001478877, -0.107753344, 0.567891511, -1.782431695, 4.84976271, }); SimpleMatrix.Matrix kernel = getKernelByQuarter(kernelQuarter); ApplyFilter(kernel, 1); }
private SimpleMatrix.Matrix getKernelByQuarter(SimpleMatrix.Matrix kernelQuarter) { int n = kernelQuarter.Columns; int N = 2 * n - 1; SimpleMatrix.Matrix m = new SimpleMatrix.Matrix(N); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { //левое m.data[i][j] = kernelQuarter.data[i][j]; //вправое m.data[i][N - 1 - j] = m.data[i][j]; //вниз m.data[N - 1 - i][j] = m.data[i][j]; //вниз вправо m.data[N - 1 - i][N - 1 - j] = m.data[i][j]; } } return(m); }
private static void DOSMTH(SimpleMatrix.Matrix t) { t = t.SwapRows(0, 1); }
static void Main(string[] args) { SimpleMatrix.Matrix m = new SimpleMatrix.Matrix(4, 4, new[] { 2d, 3, 7, 5, 11, 5, 1, 6, 8, 9, 8, 9, 15, 57, 8, 8, }); //var mr = m.RemoveRow(1); //var mc = m.RemoveColumn(1); ; //var mClone = (SimpleMatrix.Matrix)m.Clone(); //; // //double[][] arr = new[] { new[] { 0.0, 1 }, new[] { 2.0, 3 } }; //var arrClone = (double[][])arr.Clone(); //SimpleMatrix.Matrix a = new SimpleMatrix.Matrix(3, 3, new[] {2d,3,4,1,3,3,0,4,4}); //Vector v = new Vector(new double[] { 20, 16, 20d }); //var r = a.Solve(v); ; /* * var v1 =new[] { 1d, 2, 3 }; * var v2 =new[] { 5d, 6, 7 }; * * Vector aa = new Vector(v1); * Vector ab = new Vector(v2); * var T = 12*aa; * var T2 = ab * aa; * ; * //var joined = ArrayMatrix.Join(new[] { v1, v2 }.ToList()); * //SimpleMatrix.Matrix matrix = new SimpleMatrix.Matrix(joined); * ; * //SimpleMatrix.Matrix ghj = new SimpleMatrix.Matrix(3,2, new []{1,2,3,4,5,6.0}) ; * * * SimpleMatrix.Matrix t = SimpleMatrix.Matrix.Create.New(2); * t[0, 0] = 3; * t[0, 1] = 4; * t[1, 0] = 5; * t[1, 1] = 6; * * */ /* * SimpleMatrix.Matrix t = new SimpleMatrix.Matrix(7,7, new[]{ * 1.6, 7, 10, 330, -9, 25, 1.3, * 1, 9, 7, -7, 0, 11, 457, * 2, 6, -10, 33, 12, 7, 23, * 2.5, 0, 56, 89, 45, 66, -1, * 3, 0.5, 567, 12, -90, 34, 12, * 3, 0, 67, -8, 0, 0, 0, * 11, 0, 3, 0.3, 0, 0, 0 * }); * //var r = t.GetRow(0); * //var u = t[0, 3]; * var det = t.Determinant(); * ; */ SimpleMatrix.Matrix t = new SimpleMatrix.Matrix(3, 3, new[] { 1.0, 2, 3, 3, 4, 5, 1, 3, 3 }); var det = t.Determinant(); var det2 = t.Determinant(); ; /* * t[0, 0] = 1; * t[0, 1] = 2; * t[0, 2] = 3; * * t[1, 0] = 0; * t[1, 1] = 5; * t[1, 2] = 6; * * t[2, 0] = 0; * t[2, 1] = 8; * t[2, 2] = 9; */ /* * var t1 = DateTime.Now; * var d = t.Determinant(); * var t2 = DateTime.Now; * Console.WriteLine(d); * Console.WriteLine("Time:{0}", (t2 - t1).TotalSeconds); * // SimpleMatrix.Matrix B = SimpleMatrix.Matrix.Create.New(3, 4); */ /* * SimpleMatrix.Matrix A = SimpleMatrix.Matrix.Create.New(4,4); * A[0, 0] = 2.2; * A[0,1]= 1; * A[0,2]= 0.5; * A[0, 3] = 2; * * A[1, 0] = 1; * A[1, 1] = 1.3; * A[1, 2] = 2; * A[1, 3] = 1; * * A[2,0]=0.5; * A[2,1]=2; * A[2,2]=0.5; * A[2, 3] = 1.6; * * A[3, 0] = 2; * A[3, 1] = 1; * A[3, 2] = 1.6; * A[3, 3] = 2; * * * var res = LaverierFadeevaMethod.Solve(A, LaverierFadeevaSolvingOptions.FullSolving); * var a = -11; */ /* * int s = 1000; * * SimpleMatrix.Matrix A = SimpleMatrix.Matrix.Create.New(s); * * SimpleMatrix.Matrix B = SimpleMatrix.Matrix.Create.New(s); * * for (int i = 0; i < s; i++) * { * for (int j = 0; j < s; j++) * { * B[i,j] = A[i, j] = j; * } * } * * * * * var c = A; * var d = B; * DateTime z = DateTime.Now; * var v = ArrayMatrix.MultiplyN3Transpose(c, d); * DateTime z2 = DateTime.Now; * Console.WriteLine((z2 - z).TotalSeconds); * * /* * //var c = new[] { -10.0, -10, -10, -10 }; * var c = new[] { 10.0, 10, 10, 10 }; * * var a = new[] { 1.0, 2, 4, 4 }; * var b = new[] { 2.0, 6, 2, 2 }; * // var f = new[] { -18.0, -40,-46, -54 }; * var f = new[] { 18.0, 40, 46, 54 }; * * var solve = TridiagonalMatrixSolving.CyclycWithoutMinuses(a, c, b, f); * for (int i = 0; i < a.Length; i++) * { * Console.WriteLine(solve[i]); * } */ //Console.ReadLine(); }