private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1.Title  = "Select a picture";
     openFileDialog1.Filter = "All supported graphics|*.jpg;*.jpeg;*.png;*.jfif;*.bmp|" +
                              "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg;|" +
                              "Portable Network Graphic (*.png)|*.png";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         Cursor = Cursors.WaitCursor;
         foreach (string filename in openFileDialog1.FileNames)
         {
             _image = new Image <Bgr, byte>(filename);
             ImageForm form = new ImageForm(_image);
             form.TopLevel = false;
             this.panel1.Controls.Add(form);
             form.Show();
         }
         Cursor = Cursors.Default;
     }
 }
 public StrechingForm()
 {
     InitializeComponent();
     form = new ImageForm();
     form.Show();
 }
 public TresholdForm()
 {
     InitializeComponent();
     form = new ImageForm();
     form.Show();
 }
Exemplo n.º 4
0
 public PosterizationForm()
 {
     InitializeComponent();
     form = new ImageForm();
     form.Show();
 }
 public ThresholdGrayLevelForm()
 {
     InitializeComponent();
     form = new ImageForm();
     form.Show();
 }
        private unsafe void prewittToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            int m1w1 = 1;
            int m1w2 = 1;
            int m1w3 = 1;

            int m1w4 = 1;
            int m1w5 = -2;
            int m1w6 = 1;

            int m1w7 = -1;
            int m1w8 = -1;
            int m1w9 = -1;
            //-----maska2 Prewitt S
            int m2w1 = -1;
            int m2w2 = -1;
            int m2w3 = -1;

            int m2w4 = 1;
            int m2w5 = -2;
            int m2w6 = 1;

            int m2w7 = 1;
            int m2w8 = 1;
            int m2w9 = 1;


            Bitmap bitmap = new Image <Gray, byte>(GetImage()).Bitmap;

            FastBitmap bmp = new FastBitmap(bitmap);

            FastBitmap wynik = bmp;
            int        x, y;
            float      oldmin, oldmax, oldrange, scale;
            float      newmin, newmax, newrange;

            float[,] pomtab = new float[bmp.Width, bmp.Height];
            float pom;

            for (x = 0; x < wynik.Width; x++)
            {
                for (y = 0; y < wynik.Height; y++)
                {
                    pom = ((bmp[x - 1, y - 1].R * m1w1 + bmp[x, y - 1].R * m1w2 + bmp[x + 1, y - 1].R * m1w3
                            + bmp[x - 1, y].R * m1w4 + bmp[x, y].R * m1w5 + bmp[x + 1, y].R * m1w6
                            + bmp[x - 1, y + 1].R * m1w7 + bmp[x, y + 1].R * m1w8 + bmp[x + 1, y + 1].R * m1w9) ^ 2

                           + (bmp[x - 1, y - 1].R * m2w1 + bmp[x, y - 1].R * m2w2 + bmp[x + 1, y - 1].R * m2w3
                              + bmp[x - 1, y].R * m2w4 + bmp[x, y].R * m2w5 + bmp[x + 1, y].R * m2w6
                              + bmp[x - 1, y + 1].R * m2w7 + bmp[x, y + 1].R * m2w8 + bmp[x + 1, y + 1].R * m2w9) ^ 2) ^ (1 / 2);
                    pomtab[x, y] = pom;
                }
            }

            //SKALOWANIE
            //1

            oldmin = pomtab[0, 0];
            oldmax = pomtab[0, 0];

            for (x = 0; x < wynik.Width; x++)
            {
                for (y = 0; y < wynik.Height; y++)
                {
                    if (pomtab[x, y] < oldmin)
                    {
                        oldmin = pomtab[x, y];
                    }
                    if (pomtab[x, y] > oldmax)
                    {
                        oldmax = pomtab[x, y];
                    }
                }
            }

            oldrange = oldmax - oldmin;
            newmin   = 0;
            newmax   = 255;
            newrange = newmax - newmin;

            for (x = 0; x < wynik.Width; x++)
            {
                for (y = 0; y < wynik.Height; y++)
                {
                    scale       = (pomtab[x, y] - oldmin) / oldrange;
                    wynik[x, y] = Color.FromArgb((int)((newrange * scale) + newmin), (int)((newrange * scale) + newmin), (int)((newrange * scale) + newmin));
                }
            }

            ImageForm from = new ImageForm(new Image <Bgr, byte>(wynik.Unlock()));

            from.Show();
        }