コード例 #1
0
        static void Losange(MyImage Image)
        {
            int x = Image.Hauteur;
            int y = Image.Largeur;

            Pixel[,] NewMat = new Pixel[x, y];

            for (int a = 0; a < x; a++)
            {
                for (int b = 0; b < y; b++)
                {
                    NewMat[a, b] = new Pixel(0, 0, 0);
                }
            }
            int compt = 0;

            for (int i = x / 2; i < x / 1.05; i++)
            {
                for (int j = y / 4 + compt; j < y / 1.4 - compt; j++)
                {
                    NewMat[i, j] = new Pixel(255, 255, 255);
                }
                compt++;
            }
            compt = 0;
            for (int i = x / 2; i > x / 12; i--)
            {
                for (int j = y / 4 + compt; j < y / 1.4 - compt; j++)
                {
                    NewMat[i, j] = new Pixel(255, 255, 255);
                }
                compt++;
            }
            Image.From_Image_ToFile(NewMat, "FormeGeo");
        }
コード例 #2
0
        static void Rotation270(MyImage Image)
        {
            Pixel[,] Mat3 = new Pixel[Image.Largeur, Image.Hauteur];

            for (int i = 0; i < Image.Largeur; i++)
            {
                for (int j = 0; j < Image.Hauteur; j++)
                {
                    Mat3[i, j] = Image.Mat1[Image.Hauteur - j - 1, i];
                }
            }
            Pixel[,] Mat4 = new Pixel[Image.Hauteur, Image.Largeur];

            for (int i = 0; i < Image.Hauteur; i++)
            {
                for (int j = 0; j < Image.Largeur; j++)
                {
                    Mat4[i, j] = Mat3[Image.Largeur - j - 1, i];
                }
            }
            Pixel[,] Mat5 = new Pixel[Image.Largeur, Image.Hauteur];

            for (int i = 0; i < Image.Largeur; i++)
            {
                for (int j = 0; j < Image.Hauteur; j++)
                {
                    Mat5[i, j] = Mat4[Image.Hauteur - j - 1, i];
                }
            }


            Image.From_Image_ToFile(Mat4, "Rotation");
        }
コード例 #3
0
        static void Hexagone(MyImage Image)
        {
            int x = Image.Hauteur;
            int y = Image.Largeur;

            Pixel[,] NewMat = new Pixel[x, y];

            for (int a = 0; a < x; a++)
            {
                for (int b = 0; b < y; b++)
                {
                    NewMat[a, b] = new Pixel(0, 0, 0);
                }
            }

            for (double i = x / 2.9; i < x / 1.98; i++)
            {
                for (double j = y / 3; j < y / 1.6; j++)
                {
                    int I = Convert.ToInt32(i);
                    int J = Convert.ToInt32(j);
                    NewMat[I, J].R1 = 255;
                    NewMat[I, J].G1 = 255;
                    NewMat[I, J].B1 = 255;
                }
            }
            int compt = 0;

            for (double i = x / 1.98; i < x / 1.6; i++)
            {
                for (int j = y / 3 + compt; j < y / 1.6 - compt; j++)
                {
                    int I = Convert.ToInt32(i);
                    NewMat[I, j].R1 = 255;
                    NewMat[I, j].G1 = 255;
                    NewMat[I, j].B1 = 255;
                }
                compt++;
            }
            compt = 0;
            for (double i = x / 2.9; i > x / 4.3; i--)
            {
                for (int j = y / 3 + compt; j < y / 1.6 - compt; j++)
                {
                    int I = Convert.ToInt32(i);
                    NewMat[I, j].R1 = 255;
                    NewMat[I, j].G1 = 255;
                    NewMat[I, j].B1 = 255;
                }
                compt++;
            }
            Image.From_Image_ToFile(NewMat, "FormeGeo");
        }
コード例 #4
0
        static void Rotation90(MyImage MonImage)
        {
            Pixel[,] Mat3 = new Pixel[MonImage.Largeur, MonImage.Hauteur];

            for (int i = 0; i < MonImage.Largeur; i++)
            {
                for (int j = 0; j < MonImage.Hauteur; j++)
                {
                    Mat3[i, j] = MonImage.Mat1[MonImage.Hauteur - j - 1, i];
                }
            }


            MonImage.From_Image_ToFile(Mat3, "Rotation");
        }
コード例 #5
0
        static void NuanceDeGris(MyImage Image, string Nom)
        {
            Pixel[,] Mat = new Pixel[Image.Hauteur, Image.Largeur];
            for (int i = 0; i < Image.Hauteur; i++)
            {
                for (int j = 0; j < Image.Largeur; j++)
                {
                    int  M  = (Image.Mat1[i, j].R1 + Image.Mat1[i, j].G1 + Image.Mat1[i, j].B1) / 3;
                    byte M1 = Convert.ToByte(M);

                    Mat[i, j] = new Pixel(M1, M1, M1);
                }
            }
            Image.From_Image_ToFile(Mat, Nom);
        }
コード例 #6
0
        static void Rond(MyImage Image)
        {
            int x = Image.Hauteur;
            int y = Image.Largeur;

            Pixel[,] NewMat = new Pixel[x, y];
            Random R = new Random();

            for (int a = 0; a < x; a++)
            {
                for (int b = 0; b < y; b++)
                {
                    NewMat[a, b] = new Pixel(0, 0, 0);
                }
            }
            for (int a = 0; a < x; a++)
            {
                for (int b = 0; b < y; b++)
                {
                    NewMat[a, b].R1 = Convert.ToByte(R.Next(1, 255));
                    NewMat[a, b].G1 = Convert.ToByte(R.Next(1, 255));
                    NewMat[a, b].B1 = Convert.ToByte(R.Next(1, 255));
                }
            }
            double j = 0;
            double i = 0;
            int    J;
            int    I;

            for (i = 0; i < x; i++)
            {
                for (j = 0; j < y; j++)
                {
                    int    Centre1 = x / 2;
                    int    Centre2 = y / 2;
                    double D       = Math.Sqrt((i - Centre1) * (i - Centre1) + (j - Centre2) * (j - Centre2));
                    J = Convert.ToInt32(j);
                    I = Convert.ToInt32(i);
                    if (D < y / 4)
                    {
                        NewMat[I, J].R1 = 255;
                        NewMat[I, J].G1 = 255;
                        NewMat[I, J].B1 = 255;
                    }
                }
            }
            Image.From_Image_ToFile(NewMat, "FormeGeo");
        }
コード例 #7
0
        static void Negatif(MyImage Image)
        {
            Pixel[,] Mat = new Pixel[Image.Hauteur, Image.Largeur];

            for (int i = 0; i < Image.Hauteur; i++)
            {
                for (int j = 0; j < Image.Largeur; j++)
                {
                    byte R = Convert.ToByte(255 - Image.Mat1[i, j].R1);
                    byte G = Convert.ToByte(255 - Image.Mat1[i, j].G1);
                    byte B = Convert.ToByte(255 - Image.Mat1[i, j].B1);


                    Mat[i, j] = new Pixel(R, G, B);
                }
            }
            Image.From_Image_ToFile(Mat, "Negatif");
        }
コード例 #8
0
        static void InitialePrenom(MyImage Image)
        {
            int i;
            int j;
            int x = Image.Hauteur;
            int y = Image.Largeur;

            Pixel[,] Mat3 = new Pixel[Image.Hauteur, Image.Largeur];

            for (int a = 0; a < x; a++)
            {
                for (int b = 0; b < y; b++)
                {
                    Mat3[a, b] = Image.Mat1[a, b];
                }
            }
            for (i = x / 6; i < x / 1.9; i++)
            {
                for (j = y / 4; j < y / 3; j++)
                {
                    Mat3[i, j] = new Pixel(255, 255, 255);
                }
            }
            for (i = x / 6; i < x / 1.9; i++)
            {
                for (j = y / 2; j > y / 2.4; j--)
                {
                    Mat3[i, j] = new Pixel(255, 255, 255);
                }
            }
            for (i = x / 3; i < x / 2.5; i++)
            {
                for (j = y / 3; j < y / 2.4; j++)
                {
                    Mat3[i, j] = new Pixel(255, 255, 255);
                }
            }


            Image.From_Image_ToFile(Mat3, "Initiale");
        }
コード例 #9
0
        static void NoirEtBlanc(MyImage Image, string Nom)
        {
            Pixel[,] Mat = new Pixel[Image.Hauteur, Image.Largeur];

            for (int i = 0; i < Image.Hauteur; i++)
            {
                for (int j = 0; j < Image.Largeur; j++)
                {
                    int  M  = (Image.Mat1[i, j].R1 + Image.Mat1[i, j].G1 + Image.Mat1[i, j].B1) / 3;
                    byte M1 = Convert.ToByte(M);
                    if (M1 < 128)
                    {
                        Mat[i, j] = new Pixel(0, 0, 0);
                    }
                    else
                    {
                        Mat[i, j] = new Pixel(255, 255, 255);
                    }
                }
            }
            Image.From_Image_ToFile(Mat, Nom);
        }
コード例 #10
0
        static void Innovation()
        {
            byte[]  TabImage = File.ReadAllBytes("lena.bmp");
            MyImage MonImage = new MyImage(TabImage);

            for (int i = 0; i < MonImage.Hauteur; i++)
            {
                for (int j = 0; j < MonImage.Largeur; j++)
                {
                    MonImage.Mat1[i, j].R1 = 144;
                    MonImage.Mat1[i, j].G1 = 233;
                    MonImage.Mat1[i, j].B1 = 135;
                }
            }

            for (double i = MonImage.Hauteur / 1.6; i < MonImage.Hauteur; i++)
            {
                for (int j = 0; j < MonImage.Largeur; j++)
                {
                    int I = Convert.ToInt32(i);
                    MonImage.Mat1[I, j].R1 = 236;
                    MonImage.Mat1[I, j].G1 = 196;
                    MonImage.Mat1[I, j].B1 = 38;
                }
            }

            int x     = MonImage.Hauteur;
            int y     = MonImage.Largeur;
            int compt = 0;

            for (int i = x / 2; i < x / 1.1; i++)
            {
                for (int j = y / 4 + compt; j < y / 1.2 - compt; j++)
                {
                    MonImage.Mat1[i, j].R1 = 38;
                    MonImage.Mat1[i, j].G1 = 103;
                    MonImage.Mat1[i, j].B1 = 167;
                }
                compt++;
                //compt2++;
            }
            for (int i = x / 2; i > x / 20; i--)             // gros carré
            {
                for (int j = y / 4; j < y / 1.2; j++)
                {
                    MonImage.Mat1[i, j].R1 = 220;
                    MonImage.Mat1[i, j].G1 = 245;
                    MonImage.Mat1[i, j].B1 = 245;
                }
            }
            for (int i = x / 20; i < x / 3.6; i++)             // porte
            {
                for (int j = y / 2; j < y / 1.5; j++)
                {
                    MonImage.Mat1[i, j].R1 = 38;
                    MonImage.Mat1[i, j].G1 = 103;
                    MonImage.Mat1[i, j].B1 = 167;
                }
            }
            for (double i = (x / 20 + x / 3.6) / 2; i < (x / 20 + x / 3.6) / 1.8; i++)
            {
                for (double j = y / 1.6; j < y / 1.55; j++)
                {
                    int J = Convert.ToInt32(j);
                    int I = Convert.ToInt32(i);
                    MonImage.Mat1[I, J].R1 = 0;
                    MonImage.Mat1[I, J].G1 = 0;
                    MonImage.Mat1[I, J].B1 = 0;
                }
            }

            for (int i = x / 3; i < x / 2.1; i++)             // fenetre
            {
                for (int j = x / 3; j < x / 2.1; j++)
                {
                    MonImage.Mat1[i, j].R1 = 208;
                    MonImage.Mat1[i, j].G1 = 208;
                    MonImage.Mat1[i, j].B1 = 128;
                }
            }
            for (int i = x / 3; i < x / 2.1; i++)             // 2eme fenetre
            {
                for (double j = x / 1.6; j < x / 1.3; j++)
                {
                    int J = Convert.ToInt32(j);
                    MonImage.Mat1[i, J].R1 = 208;
                    MonImage.Mat1[i, J].G1 = 208;
                    MonImage.Mat1[i, J].B1 = 128;
                }
            }

            for (int i = x / 3; i > x / 20; i--)             // tronc du sapin
            {
                for (int j = y / 10; j < y / 7; j++)
                {
                    MonImage.Mat1[i, j].R1 = 27;
                    MonImage.Mat1[i, j].G1 = 86;
                    MonImage.Mat1[i, j].B1 = 0;
                }
            }
            int C = 0;

            for (int i = x / 10; i < x / 2; i++)                                   // Triangle sapin
            {
                for (int j = 0 + C; j < y / 4.2 - C; j++)
                {
                    MonImage.Mat1[i, j].R1 = 27;
                    MonImage.Mat1[i, j].G1 = 86;
                    MonImage.Mat1[i, j].B1 = 0;
                }
                C++;
            }
            C = 0;
            for (int i = x / 6; i < x / 2; i++)
            {
                for (int j = 0 + C; j < y / 4.2 - C; j++)
                {
                    MonImage.Mat1[i, j].R1 = 27;
                    MonImage.Mat1[i, j].G1 = 86;
                    MonImage.Mat1[i, j].B1 = 0;
                }
                C++;
            }
            C = 0;
            for (double i = x / 4.25; i < x / 2; i++)
            {
                for (int j = 0 + C; j < y / 4.2 - C; j++)
                {
                    int I = Convert.ToInt32(i);
                    MonImage.Mat1[I, j].R1 = 27;
                    MonImage.Mat1[I, j].G1 = 86;
                    MonImage.Mat1[I, j].B1 = 0;
                }
                C++;
            }
            C = 0;
            for (double i = x / 3.4; i < x / 2; i++)
            {
                for (int j = 0 + C; j < y / 4.2 - C; j++)
                {
                    int I = Convert.ToInt32(i);
                    MonImage.Mat1[I, j].R1 = 27;
                    MonImage.Mat1[I, j].G1 = 86;
                    MonImage.Mat1[I, j].B1 = 0;
                }
                C++;
            }
            for (double i = x / 1.25; i < x / 1.17; i++)               // soleil
            {
                for (double j = y / 10; j < y / 4; j++)
                {
                    int I = Convert.ToInt32(i);
                    int J = Convert.ToInt32(j);
                    MonImage.Mat1[I, J].R1 = 0;
                    MonImage.Mat1[I, J].G1 = 255;
                    MonImage.Mat1[I, J].B1 = 255;
                }
            }

            int C2 = 0;

            for (double i = x / 1.17; i < x / 1.11; i++)
            {
                for (int j = y / 10 + C2; j < y / 4 - C2; j++)
                {
                    int I = Convert.ToInt32(i);
                    MonImage.Mat1[I, j].R1 = 0;
                    MonImage.Mat1[I, j].G1 = 255;
                    MonImage.Mat1[I, j].B1 = 255;
                }
                C2++;
            }
            C2 = 0;
            for (double i = x / 1.25; i > x / 1.32; i--)
            {
                for (int j = y / 10 + C2; j < y / 4 - C2; j++)
                {
                    int I = Convert.ToInt32(i);
                    MonImage.Mat1[I, j].R1 = 0;
                    MonImage.Mat1[I, j].G1 = 255;
                    MonImage.Mat1[I, j].B1 = 255;
                }
                C2++;
            }

            MonImage.From_Image_ToFile(MonImage.MAT1, "Innovation");
        }
コード例 #11
0
        static void MatriceDeConvolution(MyImage Image, int[,] Mat, int b, string Nom)
        {
            Pixel[,] MatNew = new Pixel[Image.Hauteur, Image.Largeur];

            for (int a = 0; a < Image.Hauteur; a++)
            {
                for (int c = 0; c < Image.Largeur; c++)
                {
                    MatNew[a, c] = Image.Mat1[a, c];
                }
            }

            for (int i = 2; i < Image.Hauteur - 2; i++)
            {
                for (int j = 2; j < Image.Largeur - 2; j++)
                {
                    Pixel[,] Mat3 = new Pixel[5, 5];

                    for (int c = 0; c < 5; c++)
                    {
                        for (int d = 0; d < 5; d++)
                        {
                            Mat3[c, d] = Image.Mat1[i - 2 + c, j - 2 + d];
                        }
                    }

                    int B = 0, C = 0, D = 0;

                    for (int I = 0; I < 5; I++)
                    {
                        for (int J = 0; J < 5; J++)
                        {
                            B += Mat[I, J] * Mat3[I, J].R1;
                            C += Mat[I, J] * Mat3[I, J].G1;
                            D += Mat[I, J] * Mat3[I, J].B1;
                        }
                    }
                    B = B / b;
                    C = C / b;
                    D = D / b;
                    if (B < 0)
                    {
                        B = 0;
                    }
                    if (C < 0)
                    {
                        C = 0;
                    }
                    if (D < 0)
                    {
                        D = 0;
                    }
                    if (B > 255)
                    {
                        B = 255;
                    }
                    if (C > 255)
                    {
                        C = 255;
                    }
                    if (D > 255)
                    {
                        D = 255;
                    }

                    byte B1 = Convert.ToByte(B);
                    byte C1 = Convert.ToByte(C);
                    byte D1 = Convert.ToByte(D);



                    MatNew[i, j] = new Pixel(B1, C1, D1);
                }
            }
            Image.From_Image_ToFile(MatNew, Nom);
        }