private void openImageToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "Open Image"; dlg.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png, *.bmp) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.bmp"; if (dlg.ShowDialog() == DialogResult.OK) { img_ = C_lmage.C_Image_OpenImage(dlg.FileName, 1); pictureBox1.Image = C_lmage.MatToBitmap(img_); img_aux = img_.EmptyClone(); } } }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { //if (e.Button == MouseButtons.Left && start_Paint) //{ // Cv2.Line(img_aux, ini_Coord.X, ini_Coord.Y, TranslateStretchImageMousePosition(e.Location).X, // TranslateStretchImageMousePosition(e.Location).Y, color, int.Parse(textBox1.Text), LineTypes.AntiAlias); // ini_Coord = TranslateStretchImageMousePosition(e.Location); // Mat dest = new Mat(); // Mat watershed= C_lmage.C_Image_Watershed(img_aux, img_, color); // Cv2.AddWeighted(img_, 1.0, watershed, 0.9, 0.5, dest); //Combination of two images // pictureBox1.Image = C_lmage.MatToBitmap(watershed); //} if (e.Button == MouseButtons.Left && start_Paint) { Cv2.Line(img_aux, ini_Coord.X, ini_Coord.Y, TranslateStretchImageMousePosition(e.Location).X, TranslateStretchImageMousePosition(e.Location).Y, color, int.Parse(textBox1.Text), LineTypes.AntiAlias); ini_Coord = TranslateStretchImageMousePosition(e.Location); Mat dest = new Mat(); Cv2.AddWeighted(img_, 1.0, img_aux, 0.8, 0.0, dest); //Combination of two images pictureBox1.Image = C_lmage.MatToBitmap(dest); } if (e.Button == MouseButtons.Right && start_Paint) { Cv2.Line(img_aux, ini_Coord.X, ini_Coord.Y, TranslateStretchImageMousePosition(e.Location).X, TranslateStretchImageMousePosition(e.Location).Y, Scalar.Black, int.Parse(textBox1.Text), LineTypes.AntiAlias); ini_Coord = TranslateStretchImageMousePosition(e.Location); Mat dest = new Mat(); Cv2.AddWeighted(img_, 1.0, img_aux, 0.8, 0.0, dest); //Combination of two images pictureBox1.Image = C_lmage.MatToBitmap(dest); } GC.Collect(); //let w }