Facebook
From Little Shama, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 269
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace rozpoznawanie_liter
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         int[,] tablica;
  16.         int wysokosc, szerokosc, wysokosc2, szerokosc2;
  17.         Bitmap image, image2;
  18.         int[,] tablica2;
  19.  
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.  
  25.         private void button1_Click(object sender, EventArgs e)
  26.         {
  27.             OpenFileDialog openFileDialog1 = new OpenFileDialog();
  28.             openFileDialog1.Filter = "Image File|*.png";
  29.  
  30.             if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  31.             {
  32.  
  33.                 image = new Bitmap(openFileDialog1.OpenFile());
  34.                 button2.Enabled = true;
  35.                 szerokosc = image.Width;
  36.                 int a;
  37.                 wysokosc = image.Height;
  38.                 tablica = new int[szerokosc, wysokosc];
  39.                 for (int i = 0; i < szerokosc; i++)
  40.                     for (int j = 0; j < wysokosc; j++)
  41.                     {
  42.                         a = image.GetPixel(i, j).B;
  43.                         if (a == 255)
  44.                             tablica[i, j] = 0;
  45.                         if ((a < 255) & (a > 50))
  46.                             tablica[i, j] = 0;
  47.                         if (a < 49)
  48.                             tablica[i, j] = 1;
  49.                     }
  50.             }
  51.         }
  52.  
  53.         private void button2_Click(object sender, EventArgs e)
  54.         {
  55.             richTextBox1.Clear();
  56.             for (int i = 0; i < wysokosc; i++)
  57.             {
  58.                 for (int j = 0; j < szerokosc; j++)
  59.                 {
  60.                     if (tablica[j, i] == 1)
  61.                     {
  62.                         richTextBox1.SelectionColor = System.Drawing.Color.Red;
  63.                         richTextBox1.AppendText(" " + tablica[j, i].ToString());
  64.                     }
  65.                     else
  66.                     {
  67.                         richTextBox1.SelectionColor = System.Drawing.Color.Black;
  68.                         richTextBox1.AppendText(tablica[j, i].ToString());
  69.                     }
  70.                 }
  71.                 richTextBox1.AppendText("\n");
  72.             }
  73.  
  74.         }
  75.  
  76.         private void button3_Click(object sender, EventArgs e)
  77.         {
  78.             OpenFileDialog openFileDialog1 = new OpenFileDialog();
  79.             openFileDialog1.Filter = "Image File|*.png";
  80.  
  81.             if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  82.             {
  83.                 image2 = new Bitmap(openFileDialog1.OpenFile());
  84.                 szerokosc2 = image2.Width;
  85.                 int a;
  86.                 wysokosc2 = image2.Height;
  87.                 tablica2 = new int[szerokosc2, wysokosc2];
  88.                 for (int i = 0; i < szerokosc2; i++)
  89.                     for (int j = 0; j < wysokosc; j++)
  90.                     {
  91.  
  92.                         a = image2.GetPixel(i, j).B;
  93.                         if (a == 255)
  94.                             tablica2[i, j] = 0;
  95.                         if (a < 49)
  96.                             tablica2[i, j] = 1;
  97.                     }
  98.             }
  99.         }
  100.  
  101.         private void button4_Click(object sender, EventArgs e)
  102.         {
  103.             int suma = 0;
  104.             for (int i = 0; i < szerokosc2; i++)
  105.                 for (int j = 0; j < wysokosc; j++)
  106.                 {
  107.                     suma += tablica[i, j] * tablica2[i, j];
  108.                 }
  109.             label1.Text = suma.ToString();
  110.         }
  111.     }
  112. }