예제 #1
0
파일: image.cs 프로젝트: gviaud/OS-unity-5
    public void setPixels(image tab, int xOffset, int yOffset)
    {
        int h, w;       // Détecter les plus petites dimensions entre l'image donnée et "this", pour
        //        if(tab.height >= this.height && tab.width >= this.width) // éviter les "out of array exception"
        //             { h = this.height;
        //               w = this.width; }
        //        else if(tab.height >= this.height && tab.width < this.width)
        //             { h = this.height;
        //               w = tab.width;  }
        //        else if(tab.height < this.height && tab.width >= this.width)
        //             { h = tab.height;
        //               w = this.width; }
        //        else { h = tab.height;
        //               w = tab.width;  }

        for(int x = 0 ; x < tab.width ; x++)
        {
            for(int y = 0 ; y < tab.height ; y++)
            {
                this.set_r(tab.get_r(x,y), x+xOffset, y+yOffset);
                this.set_g(tab.get_g(x,y), x+xOffset, y+yOffset);
                this.set_b(tab.get_b(x,y), x+xOffset, y+yOffset);
            }
        }
    }
예제 #2
0
파일: image.cs 프로젝트: gviaud/OS-unity-5
 /* Différence maximum entre toutes les composantes de tous les pixels des images T1 et T2 */
 public static int DistanceMax(image T1, image T2, image mask)
 {
     int max = 0;
     int diff;
     for (int x = 0; x < T1.width; x++)
     {
         for(int y=0; y < T1.height;y++)
         {
             if(mask.get_r(x,y) < 0.5f)
             {
                     diff = Mathf.Abs(T1.get_r(x,y) - T2.get_r(x,y));
                 if(diff > max) max = diff;
                     diff = Mathf.Abs(T1.get_g(x,y) - T2.get_g(x,y));
                 if(diff > max) max = diff;
                     diff = Mathf.Abs(T1.get_b(x,y) - T2.get_b(x,y));
                 if(diff > max) max = diff;
             }
         }
     }
     return max;
 }