//Create Sobel kernel for Canny public static MMatrix D2Gauss_Canny(int rows, double stdDeviation1, int cols, double stdDeviation2, double theta) { MMatrix r = new MMatrix(2, 2); MMatrix u = new MMatrix(2, 1); MMatrix h = new MMatrix(); MMatrix g = new MMatrix(cols, rows); int hrows = rows / 2; int hcols = cols / 2; r[0, 0] = Math.Cos(theta); r[0, 1] = -Math.Sin(theta); r[1, 0] = -r[0, 1]; r[1, 1] = r[0, 0]; for (int i = 0; i < cols; ++i) { u[1, 0] = i - hcols; for (int j = 0; j < rows; ++j) { u[0, 0] = j - hrows; h = r * u; g[i, j] = Gauss(h[0, 0], stdDeviation1) * DGauss(h[1, 0], stdDeviation2); } } return g / g.Frobenius(); }