public void TraiterImage(ImageManipulable p_image)
        {
            byte[] raw    = p_image.Raw;
            byte[] res    = new byte[raw.Length];
            int    width  = p_image.Width;
            int    height = p_image.Height;

            byte[] donneesCourantes = new byte[this.Largeur * this.Largeur];
            for (int colonne = 0; colonne < width; colonne++)
            {
                for (int ligne = 0; ligne < height; ligne++)
                {
                    for (int composante = 0; composante < 3; composante++)
                    {
                        int posDonneesCourantes = 0;
                        for (int masqueX = -this.Largeur / 2; masqueX <= this.Largeur / 2; masqueX++)
                        {
                            int posX = Math.Min(Math.Max(0, colonne + masqueX), width - 1);
                            for (int masqueY = -this.Largeur / 2; masqueY <= this.Largeur / 2; masqueY++)
                            {
                                int posY = Math.Min(Math.Max(0, ligne + masqueY), height - 1);
                                donneesCourantes[posDonneesCourantes] = raw[(posY * width + posX) * 3 + composante];

                                ++posDonneesCourantes;
                            }
                        }
                        res[(ligne * width + colonne) * 3 + composante] = this.Transformation(donneesCourantes);
                    }
                }
            }

            Array.Copy(res, raw, raw.Length);

            this.Suivant?.TraiterImage(p_image);
        }
示例#2
0
        public void TraiterImage(ImageManipulable p_image)
        {
            //for (int ligne = 0; ligne < p_image.Height; ligne++)
            //{
            //    for (int colonne = 0; colonne < p_image.Width; colonne++)
            //    {
            //        Color couleurPixel = p_image[colonne, ligne];
            //        int luminance = (couleurPixel.R + couleurPixel.G + couleurPixel.B) / 3;
            //        Color nouvelleCouleur = Color.FromArgb(luminance, luminance, luminance);

            //        p_image[colonne, ligne] = nouvelleCouleur;
            //    }
            //}

            byte[] raw = p_image.Raw;
            for (int longueur = 0; longueur < raw.Length / 3; longueur++)
            {
                int  l3        = longueur * 3;
                byte luminance = (byte)((raw[l3] + raw[l3 + 1] + raw[l3 + 2]) / 3);
                raw[l3]     = luminance;
                raw[l3 + 1] = luminance;
                raw[l3 + 2] = luminance;
            }


            this.Suivant?.TraiterImage(p_image);
        }
示例#3
0
        private void tsmiOuvrir_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                this.m_imageManipulable = new ImageManipulable(ofd.FileName);
                pbImage.Image           = this.m_imageManipulable.Image;
            }
        }
示例#4
0
        public void TraiterImage(ImageManipulable p_image)
        {
            byte[] raw = p_image.Raw;
            for (int longueur = 0; longueur < raw.Length / 3; longueur++)
            {
                int  l3        = longueur * 3;
                byte luminance = (byte)((raw[l3] + raw[l3 + 1] + raw[l3 + 2]) / 3);
                byte valeur    = 0;
                if (luminance > this.Seuil)
                {
                    valeur = 255;
                }
                raw[l3]     = valeur;
                raw[l3 + 1] = valeur;
                raw[l3 + 2] = valeur;
            }

            this.Suivant?.TraiterImage(p_image);
        }