title: Blur algorithm with RGB
body: <p>Im trying to blur an image depending on a user input. If it is 1 then the blur image will average a 3X3 square and put it into the middle one.</p>
  
  <pre><code>P P P       All the pixels will be averaged and put into S.
  P S P
  P P P
  </code></pre>
  
  <p>I think I have come up with a correct solution that takes into the edges but the image is turning completely black. Can anyone find a problem with this code or is it another problem?</p>
  
  <pre><code>int range = blur_slider.getValue();
  
  for (int x = 0; x &lt; source.getWidth(); x++) {
      for (int y = 0; y &lt; source.getHeight(); y++) {
          double red_sum = 0.0;
          double green_sum = 0.0;
          double blue_sum = 0.0;
          // finds the min x and y values and makes sure there are no out of bounds exceptions
  
          int x_range_min = x - range;
          if (x_range_min &lt; 0) {
              x_range_min = 0;
          }
  
          int x_range_max = x + range;
          if (x_range_max &gt;= new_frame.getWidth()) {
              x_range_max = new_frame.getWidth() - 1;
          }
  
          int y_range_min = y - range;
          if (y_range_min &lt; 0) {
              y_range_min = 0;
          }
  
          int y_range_max = y + range;
          if (y_range_max &gt;= new_frame.getHeight()) {
              y_range_max = new_frame.getHeight() - 1;
          }
          // averages the pixels within the min and max values and puts it into the pixel at the center. copy new frame is the frame that has previous
          // work done on it, it is used so that new blur pixels that are set do not affect later pixels. new_frame is the main frame that will be set.
  
          for (int k = x_range_min; k &lt; x_range_max; k++) {
              for (int j = y_range_min; j &lt; y_range_max; j++) {
                  Pixel p = copy_new_frame.getPixel(x, y);
                  red_sum += p.getRed();
                  green_sum += p.getGreen();
                  blue_sum += p.getBlue();
              }
          }
          double num_pixels = x_range_max * y_range_max;
          ColorPixel tempPixel = new ColorPixel(red_sum / num_pixels, green_sum / num_pixels, blue_sum / num_pixels);
          new_frame.setPixel(x, y, tempPixel);
      }
  
  }
  frame_view.setFrame(new_frame);
  </code></pre>