Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.28 KB | None | 0 0
  1. // по горизонтали
  2.             for (int y = 0; y < im.Height; y++)
  3.             {
  4.                 for (int x = 0; x < im.Width; x++)
  5.                 {              
  6.                     sumR = 0;
  7.                     sumG = 0;
  8.                     sumB = 0;
  9.                     for (int k = 0; k < n; k++)
  10.                     {
  11.                         cur_x = x - rad + k;
  12.                         if (cur_x < 0) cur_x = 0;
  13.                         if (cur_x > im.Width - 1) cur_x = im.Width - 1;
  14.                         c = im_color[cur_x, y];
  15.                         cR = System.Convert.ToInt32(c.R);
  16.                         cG = System.Convert.ToInt32(c.G);
  17.                         cB = System.Convert.ToInt32(c.B);
  18.                         sumR += vect[k] * cR;
  19.                         sumG += vect[k] * cG;
  20.                         sumB += vect[k] * cB;                        
  21.                     }
  22.                     sumR /= sum;
  23.                     sumG /= sum;
  24.                     sumB /= sum;
  25.                     im.SetPixel(x, y, Color.FromArgb((int)sumR, (int)sumG, (int)sumB));
  26.                 }
  27.             }
  28.  
  29.              // по вертикали
  30.             for (int y = 0; y < im.Height; y++)
  31.             {
  32.                 for (int x = 0; x < im.Width; x++)
  33.                 {
  34.                     sumR = 0;
  35.                     sumG = 0;
  36.                     sumB = 0;
  37.                     for (int k = 0; k < n; k++)
  38.                     {
  39.  
  40.                      
  41.                         cur_y = y - rad + k;
  42.                         if (cur_y < 0) cur_y = 0;
  43.                         if (cur_y > im.Height - 1) cur_y = im.Height - 1;
  44.                  
  45.                         c = im_color[x, cur_y];
  46.                         cR = System.Convert.ToInt32(c.R);
  47.                         cG = System.Convert.ToInt32(c.G);
  48.                         cB = System.Convert.ToInt32(c.B);
  49.                         sumR += vect[k] * cR;
  50.                         sumG += vect[k] * cG;
  51.                         sumB += vect[k] * cB;
  52.  
  53.                     }
  54.                     sumR /= sum;
  55.                     sumG /= sum;
  56.                     sumB /= sum;
  57.                     im.SetPixel(x, y, Color.FromArgb((int)sumR, (int)sumG, (int)sumB));
  58.                 }
  59.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement