SHARE
TWEET

filter_morec_middle

biker_dev Jun 30th, 2020 (edited) 908 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     for(int i = 1; i < height; i++)
  2.     {
  3.  
  4.         for(int j = 1; j < width; j++)
  5.         {
  6.  
  7.             if( (1 <= i && i <= height - 2)  && (1 <= j && j <= width - 2))
  8.             {
  9.  
  10.                 average_red_middle   = image[i][j].rgbtRed   + image[i][j - 1].rgbtRed   + image[i - 1][j - 1].rgbtRed   + image[i - 1][j].rgbtRed   + image[i - 1][j + 1].rgbtRed   + image[i][j + 1].rgbtRed   + image[i + 1][ j + 1].rgbtRed + image[i + 1][j].rgbtRed     + image[i + 1][j - 1].rgbtRed;
  11.                 average_green_middle = image[i][j].rgbtGreen + image[i][j - 1].rgbtGreen + image[i - 1][j - 1].rgbtGreen + image[i - 1][j].rgbtGreen + image[i - 1][j + 1].rgbtGreen + image[i][j + 1].rgbtGreen + image[i + 1][ j + 1].rgbtGreen + image[i + 1][j].rgbtGreen + image[i + 1][j - 1].rgbtGreen;
  12.                 average_blue_middle  = image[i][j].rgbtBlue  + image[i][j - 1].rgbtBlue  + image[i - 1][j - 1].rgbtBlue  + image[i - 1][j].rgbtBlue  + image[i - 1][j + 1].rgbtBlue  + image[i][j + 1].rgbtBlue  + image[i + 1][ j + 1].rgbtBlue + image[i + 1][j].rgbtBlue   + image[i + 1][j - 1].rgbtBlue;
  13.  
  14.                 image[i][j].rgbtRed   = round((float)(average_red_middle   / 9));
  15.                 image[i][j].rgbtGreen = round((float)(average_green_middle / 9));
  16.                 image[i][j].rgbtBlue  = round((float)(average_blue_middle  / 9));
  17.  
  18.             }
  19.  
  20.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top