title: Image blurring in C++. Problem with copy of matrix
body: <p>I am inputting a matrix of black/white pixel values and then I am blurring the inside using an averaging technique. I have the program looping through properly but I need a constant copy of the original matrix for the for loops to use when stepping through. How can I  do this?</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  /****blurImage*****************************************************************************************************
   * main -- Program to blur a grayscale image given the pixel values and their location
   * 
   * Arguments: none
   * 
   * returns: 0
   *****************************************************************************************************************/
  
  void blurImage(int matrix[100][100], int matRow, int matCol, int image[100][100]);
  
  int main(){
  
      int matRow;
      int matCol;
      bool checkDataOk;
      int matrix[100][100];
      int image[100][100];
  
      cout &lt;&lt; "Enter Image Width (in pixels):";
      cin &gt;&gt; matCol;
  
      cout &lt;&lt; "Enter Image Height (in pixels):";
      cin &gt;&gt; matRow;
  
      if (matRow &lt;=0 || matCol &lt;=0 )
          checkDataOk = false;
      else checkDataOk = true;
  
  
      if(checkDataOk){
  
          cout &lt;&lt; "Enter Pixel Values (left--&gt;right):" &lt;&lt; endl;
          int tmp;
          for (int i = 0; i &lt; matRow; i++)
          {
              for (int j = 0 ; j &lt; matCol; j++)
              {
                  cin &gt;&gt; tmp;
                  matrix[i][j] = tmp;
              }
          }
  
          blurImage(matrix, matRow, matCol, image);
  
          cout &lt;&lt; endl;
          cout &lt;&lt; "Output:" &lt;&lt; endl;
          for(int i=0; i&lt;matRow; i++){
              for(int j=0; j&lt;matCol; j++){
                  cout &lt;&lt; matrix[i][j] &lt;&lt; endl;
              }
          }
      }
      else cout &lt;&lt; "Invalid Row/Column size";
  
      return 0;
  }
  
  void blurImage(int matrix[100][100], int matRow, int matCol, int image[100][100]){
  
      for(int i=1; i&lt;(matRow-1); i++){        // start index at 1 and stop at -1 so we don't access outside the image
          for(int j=1; j&lt;(matCol-1); j++){
              int total = 0;
  
              for(int n=(i-1); n&lt;(i+2); n++){ // start at the top left corner of our current index and loop the 3x3 sub-matrix adding to the total
                  for(int m=(j-1); m&lt;(j+2); m++){
                      image = matrix;
                      total += image[n][m];
                  }
              }
  
              int avg = total/9;              // get the average, and set the current index to the average
              matrix[i][j] = avg;
          }
      }
  
  }
  </code></pre>
  
  <p>If I input this 6x5 matrix: </p>
  
  <pre><code>0   0   255 0   0
  0   255 0   255 0
  255 255 0   255 255
  255 255 255 255 255
  255 0   0   0   255
  255 0   0   0   255
  0   0   255 0   0
  </code></pre>
  
  <p>I should get:</p>
  
  <pre><code>0   0   255 0   0
  0   113 141 113 0 
  255 170 198 170 255 
  255 170 141 170 255 
  255 141 85  141 255 
  255 0   0   0   255 
  0   0   255 0   0
  </code></pre>