Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter           = @"Imagen|*.jpg;*.jpeg;*.jpe;*.jfif;*.png;*.gif;*.ico;*.tif;*.tiff;*.bmp";
            fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            fileDialog.Title            = @"Porfavor seleccione una imagen.";
            DialogResult result = fileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                actualImage    = (Bitmap)Image.FromFile(fileDialog.FileName);
                actualPixels   = KernelController.GetBitMapColorMatrix(actualImage);
                picture1.Image = Image.FromFile(fileDialog.FileName);
                picture2.Image = Image.FromFile(fileDialog.FileName);

                kernel.SelectedIndex = 8;
                filter.SelectedIndex = 0;

                showComponents();
                fileLabel.Text = fileDialog.SafeFileName;
            }
            else
            {
                MessageBox.Show(@"Error al leer el archivo.");
            }
        }
Exemplo n.º 2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedIndex = filter.SelectedIndex;

            //Select filter

            // 0 -> Default
            // 1 -> Black and White
            // 2 -> Sepia

            switch (selectedIndex)
            {
            case 0:
                picture2.Image = actualImage;
                break;

            case 1:
                picture2.Image = PictureController.convertToGrayScale(actualImage);
                break;

            case 2:
                picture2.Image = PictureController.convertToSepia(actualImage);
                break;

            default:
                picture1.Image = actualImage;
                picture2.Image = actualImage;
                break;
            }

            actualPixels = KernelController.GetBitMapColorMatrix((Bitmap)picture2.Image);

            kernel.SelectedIndex = 8;
        }
Exemplo n.º 3
0
        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            editKernel.Visible = false;

            //Select kernel

            // 0 -> Difuminado
            // 1 -> Realzar
            // 2 -> Sobel Inferior
            // 3 -> Sobel Superior
            // 4 -> Sobel Izquierdo
            // 5 -> Sobel Derecho
            // 6 -> Contorno
            // 7 -> Afilar
            // 8 -> Original
            // 9 -> Personalizado

            int selectedIndex = kernel.SelectedIndex;

            Color[][] picture = actualPixels;

            switch (selectedIndex)
            {
            case 0:
                picture2.Image =
                    KernelController.applyKernel(picture, Difuminado);
                break;

            case 1:
                picture2.Image =
                    KernelController.applyKernel(picture, Realzar);
                break;

            case 2:
                picture2.Image =
                    KernelController.applyKernel(picture, Sobel_Inferior);
                break;

            case 3:
                picture2.Image =
                    KernelController.applyKernel(picture, Sobel_Superior);
                break;

            case 4:
                picture2.Image =
                    KernelController.applyKernel(picture, Sobel_Izquierdo);
                break;

            case 5:
                picture2.Image =
                    KernelController.applyKernel(picture, Sobel_Derecho);
                break;

            case 6:
                picture2.Image =
                    KernelController.applyKernel(picture, Contorno);
                break;

            case 7:
                picture2.Image =
                    KernelController.applyKernel(picture, Afilar);
                break;

            case 8:
                picture2.Image =
                    KernelController.applyKernel(picture, Original);
                break;

            case 9:
                editKernel.Visible = true;
                picture2.Image     =
                    KernelController.applyKernel(picture, KernelController.Personalizado);
                break;

            default:
                picture2.Image = picture1.Image;
                break;
            }
        }