title: CS50(2019) problem set "Filter": "blur" somehow not working correctly
body: <p>So, I have spent about 5 hours+ trying to figure out what is wrong with my code. I have tried debug50 with a 3x3 file I have manually created in Paint and everything seemed to work as intended; each pixel makes a 3x3 sweep around itself and disregards pixels that do not exist, like the ones in the corners or around edges. The final average values for each of the colors were also correct. Somehow, though, when I checked with check50, it gave out the following message: </p>
  
  <p><img src="https://i.stack.imgur.com/QFvCh.png" alt=""></p>
  
  <p>With countless tweaking and head-scratching, I have decided that it was probably time for me to turn to the community for help. Here's my code:</p>
  
  <pre><code>{
      for (int h = 0; h &lt; height; h++)
      {
          for (int w = 0; w &lt; width; w++)
          {
              int avgfordiv = 0;
              int neighvalgreen = 0;
              int neighvalblue = 0;
              int neighvalred = 0;
  
              for (int hh = -1; hh &lt; 2; hh++)
              {
                  for (int ww = -1; ww &lt; 2; ww++)
                  {
                      if ((h+hh) != height &amp;&amp; (w+ww) != width &amp;&amp; (h+hh) != -1 &amp;&amp; (w+ww) != -1)
                      {
                          //sweep
                          avgfordiv++;//count up for division
                          neighvalgreen += image[h + hh][w + ww].rgbtGreen;
                          neighvalred += image[h + hh][w + ww].rgbtRed;
                          neighvalblue += image[h + hh][w + ww].rgbtBlue;
                      }
                  }
              }
              //add values to pixels
               image[h][w].rgbtGreen = (int)(round((float)neighvalgreen / avgfordiv));
               image[h][w].rgbtBlue = (int)(round((float)neighvalblue / avgfordiv));
               image[h][w].rgbtRed = (int)(round((float)neighvalred / avgfordiv));
  
              //check cap
               if (image[h][w].rgbtGreen &lt;= 255)
                  {}
              else
                  image[h][w].rgbtGreen %= 255;
  
              if (image[h][w].rgbtRed &lt;= 255)
                  {}
              else
                  image[h][w].rgbtRed %= 255;
  
              if (image[h][w].rgbtBlue &lt;= 255)
                  {}
              else
                  image[h][w].rgbtBlue %= 255;
          }
      }
      return;
  }
  </code></pre>