Example #1
0
       //---------------------------------------------------------------------------------------------
       // colour normalisation
       //---------------------------------------------------------------------------------------------
       public void colourNormalise(classimage sourceimg, int multiplier)
       {
           int x,y,c,p,av_r=0,av_g=0,av_b=0;
           int[] col = new int[3];

           sourceimg.averageColour(0,0,width,height,ref av_r,ref av_g,ref av_b);

           for (x=0;x<width;x++)
               for (y=0;y<height;y++)
	           {
	               for (c=0;c<3;c++) col[c] = sourceimg.image[x,y,c];

	               col[0] -= av_r;
	               col[1] -= av_g;
	               col[2] -= av_b;

	               for (c=0;c<3;c++)
	               {
	                   p = 127 + (col[c]*multiplier);
	                   if (p<1) p=1;
	                   if (p>255) p=255;
		               image[x,y,c]=(Byte)p;
	               }
	           }
       }