private void 엠보싱ToolStripMenuItem_Click(object sender, EventArgs e) { double[,] _b = new double[, ] { { -3, -1, 0 }, { -1, 1, 1 }, { 0, 1, 3 } }; CvMat b = CvMat.FromArray(_b); dst = new IplImage(src.Size, BitDepth.U8, 3); Cv.Filter2D(src, dst, b, new CvPoint(-1, -1)); pictureBoxIpl2.ImageIpl = dst; }
public IplImage SunMyung3(IplImage gray) { double[,] _b = new double[, ] { { -1, -1, -1 }, { -1, 9, -1 }, { -1, -1, -1 } }; using (CvMat b = CvMat.FromArray(_b)) using (IplImage temp = new IplImage(gray.Size, BitDepth.U8, 1)) { Cv.Filter2D(gray, temp, b, new CvPoint(-1, -1)); maskimg = temp.Clone(); } return(maskimg); }
public IplImage SunMyung(IplImage src_tmp) { double[,] _b = new double[, ] { { 0, -1, 0 }, { -1, 5, -1 }, { 0, -1, 0 } }; using (CvMat b = CvMat.FromArray(_b)) using (IplImage temp = new IplImage(src_tmp.Size, BitDepth.U8, 1)) using (IplImage s1 = new IplImage(src_tmp.Size, BitDepth.U8, 1)) // 추가 { Cv.CvtColor(src_tmp, s1, ColorConversion.BgrToGray); // src를 그레이로 s1에 저장 Cv.Filter2D(s1, temp, b, new CvPoint(-1, -1)); maskimg = temp.Clone(); } return(maskimg); }
public MatTest() { // 行列aとbを初期化 // aはオーソドックスに1次元配列で元データを指定 double[] _a = new double[]{ 1, 2, 3, 4, 5, 6, 7, 8, 9, }; // bは二次元配列で指定してみる. 1チャンネルの行列ならこちらの方が楽. double[,] _b = new double[,]{ {1, 4, 7}, {2, 5, 8}, {3, 6, 9} }; // 色(RGB3チャンネル)の配列 CvColor[,] _c = new CvColor[,]{ {CvColor.Red, CvColor.Green, CvColor.Blue}, {CvColor.Brown, CvColor.Cyan, CvColor.Pink}, {CvColor.Magenta, CvColor.Navy, CvColor.Violet} }; using (CvMat a = new CvMat(3, 3, MatrixType.F64C1, _a)) // 元データが1次元配列の場合 using (CvMat b = CvMat.FromArray(_b)) // 元データが2次元配列の場合 using (CvMat c = CvMat.FromArray(_c, MatrixType.U8C3)) // 多チャンネル配列の場合 { // aとbの値を表示 Console.WriteLine("a : \n{0}", a); Console.WriteLine("b : \n{0}", b); // 行列の掛け算 Console.WriteLine("A * B : \n{0}", a * b); // 加算、減算 Console.WriteLine("a + b : \n{0}", a + b); Console.WriteLine("a - b : \n{0}", a - b); // 論理演算 Console.WriteLine("a & b : \n{0}", a & b); Console.WriteLine("a | b : \n{0}", a | b); Console.WriteLine("~a : \n{0}", ~a); } // CvMatは大してメモリを食うことはないと思われるので、 // いちいちusingせずGCにまかせてもいいかも。 Console.WriteLine("press any key to quit"); Console.Read(); }
//수직 엣지 찾기 public IplImage V_Edge(IplImage src) //그레이 변환된 이미지 { double[,] _b = new double[, ] { { -1, 0, 1 }, { -1, 0, 1 }, { -1, 0, 1 } }; using (CvMat b = CvMat.FromArray(_b)) using (IplImage temp = new IplImage(src.Size, BitDepth.U8, 1)) { Cv.Filter2D(src, temp, b, new CvPoint(-1, -1)); Cv.Threshold(temp, temp, 80, 255, ThresholdType.BinaryInv); //이진화 maskimg = temp.Clone(); } return(maskimg); }