using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace rozpoznawanie_liter { public partial class Form1 : Form { int[,] tablica; int wysokosc, szerokosc, wysokosc2, szerokosc2; Bitmap image, image2; int[,] tablica2; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Image File|*.png"; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { image = new Bitmap(openFileDialog1.OpenFile()); button2.Enabled = true; szerokosc = image.Width; int a; wysokosc = image.Height; tablica = new int[szerokosc, wysokosc]; for (int i = 0; i < szerokosc; i++) for (int j = 0; j < wysokosc; j++) { a = image.GetPixel(i, j).B; if (a == 255) tablica[i, j] = 0; if ((a < 255) & (a > 50)) tablica[i, j] = 0; if (a < 49) tablica[i, j] = 1; } } } private void button2_Click(object sender, EventArgs e) { richTextBox1.Clear(); for (int i = 0; i < wysokosc; i++) { for (int j = 0; j < szerokosc; j++) { if (tablica[j, i] == 1) { richTextBox1.SelectionColor = System.Drawing.Color.Red; richTextBox1.AppendText(" " + tablica[j, i].ToString()); } else { richTextBox1.SelectionColor = System.Drawing.Color.Black; richTextBox1.AppendText(tablica[j, i].ToString()); } } richTextBox1.AppendText("\n"); } } private void button3_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Image File|*.png"; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { image2 = new Bitmap(openFileDialog1.OpenFile()); szerokosc2 = image2.Width; int a; wysokosc2 = image2.Height; tablica2 = new int[szerokosc2, wysokosc2]; for (int i = 0; i < szerokosc2; i++) for (int j = 0; j < wysokosc; j++) { a = image2.GetPixel(i, j).B; if (a == 255) tablica2[i, j] = 0; if (a < 49) tablica2[i, j] = 1; } } } private void button4_Click(object sender, EventArgs e) { int suma = 0; for (int i = 0; i < szerokosc2; i++) for (int j = 0; j < wysokosc; j++) { suma += tablica[i, j] * tablica2[i, j]; } label1.Text = suma.ToString(); } } }