private Mat generateThumbnail(Mat input) { MatImage m1 = new MatImage(input); m1.ResizeTo(150, 150); return(m1.Out()); }
private void refresh(bool colored) { pic1Copy = pic1.Clone(); pic2Copy = pic2.Clone(); if (!colored) { map1.DrawTo(pic1Copy); map2.DrawTo(pic2Copy); } else { map1.DrawColorTo(pic1Copy); map2.DrawColorTo(pic2Copy); } MatImage m1 = new MatImage(pic1Copy); m1.ResizeTo(pictureBox1.Width, pictureBox1.Height); pictureBox1.Image = m1.Out().Bitmap; MatImage m2 = new MatImage(pic2Copy); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); pictureBox2.Image = m2.Out().Bitmap; }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { int firstAppear = 0; bool blackOrWhite = false; // false=black foreach (ColorfulContourMap cmap in Form1.blackContourMaps) { if (cmap.imageIndex == num) { blackOrWhite = false; goto black; } firstAppear++; } firstAppear=0; foreach (ColorfulContourMap cmap in Form1.whiteContourMaps) { if (cmap.imageIndex == num-Form1.blackSourceImages.Count) { blackOrWhite = true; break; } firstAppear++; } black: if (!blackOrWhite) // black { Mat img1 = Form1.blackSourceImages[num].Clone(); Mat img2 = Form1.blackSourceImages[num].Clone(); img2.SetTo(new MCvScalar(255,255,255)); //Form1.blackContourMaps[firstAppear + listBox1.SelectedIndex].DrawTo(img1); //Form1.blackContourMaps[firstAppear + listBox1.SelectedIndex].DrawColorTo(img2); { MatImage m1 = new MatImage(img1); m1.ResizeTo(pictureBox1.Width,pictureBox1.Height); img1 = m1.Out(); } pictureBox1.Image = img1.Bitmap; { MatImage m2 = new MatImage(img2); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); img2 = m2.Out(); } pictureBox2.Image = img2.Bitmap; } else // white { Mat img1 = Form1.whiteSourceImages[num - Form1.blackSourceImages.Count].Clone(); Mat img2 = Form1.whiteSourceImages[num - Form1.blackSourceImages.Count].Clone(); img2.SetTo(new MCvScalar(0)); //Form1.whiteContourMaps[firstAppear + listBox1.SelectedIndex].DrawTo(img1); //Form1.whiteContourMaps[firstAppear + listBox1.SelectedIndex].DrawColorTo(img2); { MatImage m1 = new MatImage(img1); m1.ResizeTo(pictureBox1.Width, pictureBox1.Height); img1 = m1.Out(); } pictureBox1.Image = img1.Bitmap; { MatImage m2 = new MatImage(img2); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); img2 = m2.Out(); } pictureBox2.Image = img2.Bitmap; } }
private Mat generateThumbnail(Mat input) { MatImage m1 = new MatImage(input); m1.ResizeTo(150, 150); return m1.Out(); }
private void displayFragments(PictureBox pb) { // determine the index of the first contour map for a image int firstAppear = 0; bool blackOrWhite = false; foreach (ColorfulContourMap cmap in Form1.blackContourMaps) { if (cmap.imageIndex == num) { blackOrWhite = false; goto black; } firstAppear++; } firstAppear = 0; foreach (ColorfulContourMap cmap in Form1.whiteContourMaps) { if (cmap.imageIndex == num - Form1.blackSourceImages.Count) { blackOrWhite = true; break; } firstAppear++; } black: if (!blackOrWhite) { Mat img1 = new Mat(); if (pb == pictureBox3) { ind1 = firstAppear + listBox1.SelectedIndex; img1 = Form1.blackCroppedImages[ind1].Clone(); Form1.blackContourMaps[ind1].DrawTo(img1); } else { ind2 = firstAppear + listBox1.SelectedIndex; img1 = Form1.blackCroppedImages[ind2].Clone(); Form1.blackContourMaps[ind2].DrawTo(img1); } { MatImage m2 = new MatImage(img1); m2.ResizeTo(pb.Width, pb.Height); img1 = m2.Out(); } pb.Image = img1.Bitmap; blackOWhite = false; } else { Mat img1 = new Mat(); if (pb == pictureBox3) { ind1 = firstAppear + listBox1.SelectedIndex; img1 = Form1.whiteCroppedImages[ind1].Clone(); Form1.whiteContourMaps[ind1].DrawTo(img1); } else { ind2 = firstAppear + listBox1.SelectedIndex; img1 = Form1.whiteCroppedImages[ind2].Clone(); Form1.whiteContourMaps[ind2].DrawTo(img1); } { MatImage m2 = new MatImage(img1); m2.ResizeTo(pb.Width, pb.Height); img1 = m2.Out(); } pb.Image = img1.Bitmap; blackOWhite = true; } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { int firstAppear = 0; bool blackOrWhite = false; // false=black foreach (ColorfulContourMap cmap in Form1.blackContourMaps) { if (cmap.imageIndex == num) { blackOrWhite = false; goto black; } firstAppear++; } firstAppear = 0; foreach (ColorfulContourMap cmap in Form1.whiteContourMaps) { if (cmap.imageIndex == num - Form1.blackSourceImages.Count) { blackOrWhite = true; break; } firstAppear++; } black : if (!blackOrWhite) // black { Mat img1 = Form1.blackSourceImages[num].Clone(); Mat img2 = Form1.blackSourceImages[num].Clone(); img2.SetTo(new MCvScalar(255, 255, 255)); //Form1.blackContourMaps[firstAppear + listBox1.SelectedIndex].DrawTo(img1); //Form1.blackContourMaps[firstAppear + listBox1.SelectedIndex].DrawColorTo(img2); { MatImage m1 = new MatImage(img1); m1.ResizeTo(pictureBox1.Width, pictureBox1.Height); img1 = m1.Out(); } pictureBox1.Image = img1.Bitmap; { MatImage m2 = new MatImage(img2); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); img2 = m2.Out(); } pictureBox2.Image = img2.Bitmap; } else // white { Mat img1 = Form1.whiteSourceImages[num - Form1.blackSourceImages.Count].Clone(); Mat img2 = Form1.whiteSourceImages[num - Form1.blackSourceImages.Count].Clone(); img2.SetTo(new MCvScalar(0)); //Form1.whiteContourMaps[firstAppear + listBox1.SelectedIndex].DrawTo(img1); //Form1.whiteContourMaps[firstAppear + listBox1.SelectedIndex].DrawColorTo(img2); { MatImage m1 = new MatImage(img1); m1.ResizeTo(pictureBox1.Width, pictureBox1.Height); img1 = m1.Out(); } pictureBox1.Image = img1.Bitmap; { MatImage m2 = new MatImage(img2); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); img2 = m2.Out(); } pictureBox2.Image = img2.Bitmap; } }
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) { pic1Copy = pic1.Clone(); pic2Copy = pic2.Clone(); map1.DrawTo(pic1Copy); map2.DrawTo(pic2Copy); edgeMatch = DNAUtil.partialMatch(DNA1, DNA2); List<Point> pointToDraw1 = new List<Point>(); List<Point> pointToDraw2 = new List<Point>(); for (int i = edgeMatch.t11; i < edgeMatch.t12; i++) { pointToDraw1.Add(new Point((int)DNA1[i].x, (int)DNA1[i].y)); } for (int i = edgeMatch.t21; i < edgeMatch.t22; i++) { pointToDraw2.Add(new Point((int)DNA2[i].x, (int)DNA2[i].y)); } CvInvoke.Polylines(pic1Copy, pointToDraw1.ToArray(), false, new Bgr(0, 255, 0).MCvScalar, 2); CvInvoke.Polylines(pic2Copy, pointToDraw2.ToArray(), false, new Bgr(0, 255, 0).MCvScalar, 2); MatImage m1 = new MatImage(pic1Copy); m1.ResizeTo(pictureBox1.Width, pictureBox1.Height); pictureBox1.Image = m1.Out().Bitmap; MatImage m2 = new MatImage(pic2Copy); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); pictureBox2.Image = m2.Out().Bitmap; } else { pic1Copy = pic1.Clone(); pic2Copy = pic2.Clone(); map1.DrawTo(pic1Copy); map2.DrawTo(pic2Copy); edgeMatch = DNAUtil.partialColorMatch(DNA1, DNA2); List<Point> pointToDraw1 = new List<Point>(); List<Point> pointToDraw2 = new List<Point>(); if (edgeMatch.t11 > edgeMatch.t12) { for (int i = edgeMatch.t12; i < edgeMatch.t11; i++) { pointToDraw1.Add(new Point((int)DNA1[i].x, (int)DNA1[i].y)); } } else { for (int i = edgeMatch.t11; i < edgeMatch.t12; i++) { pointToDraw1.Add(new Point((int)DNA1[i].x, (int)DNA1[i].y)); } } if (edgeMatch.t21 > edgeMatch.t22) { for (int i = edgeMatch.t22; i < edgeMatch.t21; i++) { pointToDraw2.Add(new Point((int)DNA2[i].x, (int)DNA2[i].y)); } } else { for (int i = edgeMatch.t21; i < edgeMatch.t22; i++) { pointToDraw2.Add(new Point((int)DNA2[i].x, (int)DNA2[i].y)); } } CvInvoke.Polylines(pic1Copy, pointToDraw1.ToArray(), false, new Bgr(0, 255, 0).MCvScalar, 2); CvInvoke.Polylines(pic2Copy, pointToDraw2.ToArray(), false, new Bgr(0, 255, 0).MCvScalar, 2); MatImage m1 = new MatImage(pic1Copy); m1.ResizeTo(pictureBox1.Width, pictureBox1.Height); pictureBox1.Image = m1.Out().Bitmap; MatImage m2 = new MatImage(pic2Copy); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); pictureBox2.Image = m2.Out().Bitmap; } }
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) { pic1Copy = pic1.Clone(); pic2Copy = pic2.Clone(); map1.DrawTo(pic1Copy); map2.DrawTo(pic2Copy); edgeMatch = DNAUtil.partialMatch(DNA1, DNA2); List <Point> pointToDraw1 = new List <Point>(); List <Point> pointToDraw2 = new List <Point>(); for (int i = edgeMatch.t11; i < edgeMatch.t12; i++) { pointToDraw1.Add(new Point((int)DNA1[i].x, (int)DNA1[i].y)); } for (int i = edgeMatch.t21; i < edgeMatch.t22; i++) { pointToDraw2.Add(new Point((int)DNA2[i].x, (int)DNA2[i].y)); } CvInvoke.Polylines(pic1Copy, pointToDraw1.ToArray(), false, new Bgr(0, 255, 0).MCvScalar, 2); CvInvoke.Polylines(pic2Copy, pointToDraw2.ToArray(), false, new Bgr(0, 255, 0).MCvScalar, 2); MatImage m1 = new MatImage(pic1Copy); m1.ResizeTo(pictureBox1.Width, pictureBox1.Height); pictureBox1.Image = m1.Out().Bitmap; MatImage m2 = new MatImage(pic2Copy); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); pictureBox2.Image = m2.Out().Bitmap; } else { pic1Copy = pic1.Clone(); pic2Copy = pic2.Clone(); map1.DrawTo(pic1Copy); map2.DrawTo(pic2Copy); edgeMatch = DNAUtil.partialColorMatch(DNA1, DNA2); List <Point> pointToDraw1 = new List <Point>(); List <Point> pointToDraw2 = new List <Point>(); if (edgeMatch.t11 > edgeMatch.t12) { for (int i = edgeMatch.t12; i < edgeMatch.t11; i++) { pointToDraw1.Add(new Point((int)DNA1[i].x, (int)DNA1[i].y)); } } else { for (int i = edgeMatch.t11; i < edgeMatch.t12; i++) { pointToDraw1.Add(new Point((int)DNA1[i].x, (int)DNA1[i].y)); } } if (edgeMatch.t21 > edgeMatch.t22) { for (int i = edgeMatch.t22; i < edgeMatch.t21; i++) { pointToDraw2.Add(new Point((int)DNA2[i].x, (int)DNA2[i].y)); } } else { for (int i = edgeMatch.t21; i < edgeMatch.t22; i++) { pointToDraw2.Add(new Point((int)DNA2[i].x, (int)DNA2[i].y)); } } CvInvoke.Polylines(pic1Copy, pointToDraw1.ToArray(), false, new Bgr(0, 255, 0).MCvScalar, 2); CvInvoke.Polylines(pic2Copy, pointToDraw2.ToArray(), false, new Bgr(0, 255, 0).MCvScalar, 2); MatImage m1 = new MatImage(pic1Copy); m1.ResizeTo(pictureBox1.Width, pictureBox1.Height); pictureBox1.Image = m1.Out().Bitmap; MatImage m2 = new MatImage(pic2Copy); m2.ResizeTo(pictureBox2.Width, pictureBox2.Height); pictureBox2.Image = m2.Out().Bitmap; } }