private void recognize(ObjectImg Img) { int time = Convert.ToInt32(textBox1.Text); string str; int len; Random rand = new Random(); Img.griding(dataGridView2, Img.MassPer); for (int j = 0; j < time; j++) { // выбираем картинку // Img.kl = rand.Next(0, 3) + 1; Text = new DirectoryInfo(@"..\bmp\" + Img.kl).GetFiles().Length.ToString(); len = Convert.ToInt32(Text); pictureBox1.Image = new Bitmap(@"..\bmp\" + Img.kl + @"\" + (rand.Next(0, len) + 1) + ".bmp"); Img.bmp = new Bitmap(pictureBox1.Image); // находим составляющие // Img.MassImg = Img.ImgToMat(Img.bmp); Img.sumAndY(); Img.addLine(dataGridView2, Img.sum, "sum"); Img.addLine(dataGridView2, Img.lineY, "Y"); Img.defineKod(); // вычисляем лямбды // int ourkl = 0; int maxS = -1000; for (int i = 0; i < 3; i++) { lym[i].s = findS(lym[i].mass, Img.lineY); if (lym[i].s > maxS) { maxS = lym[i].s; ourkl = i + 1; } } if (Img.kl != ourkl) { for (int i = 0; i < Img.lineY.Length; i++) { lym[Img.kl - 1].mass[i] += Img.lineY[i]; lym[ourkl - 1].mass[i] -= Img.lineY[i]; } } Img.addLine(dataGridView3, lym[0].mass, "lym"); Img.addLine(dataGridView4, lym[1].mass, "lym"); Img.addLine(dataGridView5, lym[2].mass, "lym"); } pictureBox1.Image = new Bitmap(@"..\bmp\OK.bmp"); writeFile(); }
private void button1_Click(object sender, EventArgs e) { pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = ("Image Files(*.BMP)|*.BMP"); if (ofd.ShowDialog() == DialogResult.OK) { try { pictureBox1.Image = new Bitmap(ofd.FileName); myPic = new ObjectImg(pictureBox1.Image); myPic.MassImg = myPic.ImgToMat(myPic.bmp); myPic.bmp = new Bitmap(pictureBox1.Image); myPic.griding(dataGridView1, myPic.MassImg); fuckYoo(dataGridView2, myPic.MassImg); findImg(); } catch { MessageBox.Show("Невозможно открыть файл", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }