title: image smoothing in c
body: <p>Alright so I'm trying to have a user input the number of columns and rows and then have the output bring up a random number matrix followed by a smoothed image matrix that finds the mean filter for every pixel in the array. Right now I have it to where it can give me a random number matrix, but the smoothed matrix is all out of whack. Right now the code I have written is just focusing on integers that have 4 neighbors, but clearly I have done something wrong.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;conio.h&gt;
  #include &lt;time.h&gt;
  // function that randomly generates numbers 
  void fillArray(int a[10][20], int m, int n)
  {
    int random;
    int i,j;   
        for (i=0;i&lt;m;i++)
        {
            for (j=0;j&lt;n;j++)
            {
                             random=rand()%100;
                             a[i][j]=random;
                             }
                             }
    }
    // function that prints the first matrix of random numbers
    void printarray (int a[10][20], int m, int n)
   {
   int i,j;
  for (i=0;i&lt;m;i++) 
  {
      for (j=0;j&lt;n;j++)
          {
                       printf("%4d", a[i][j]);
                       }
                       printf("\n");
                       }
    }
    // function that finds the mean for any number and its 4 nieghbors 
    void smooth (int a[10][20], int m, int n)
   {
  
   int i,j;
   for (i=1;i&lt;m;i++) 
  {
      for (j=1;j&lt;n;j++)
      {
          a[i][j]=a[i][j]=(a[i-1][j]+a[i][j-1]+a[i+1][j]+a[i][j+1])/4;
          printf("%4d",a[i][j]);
          }
          printf("\n");
   }
   }
   int main()
  {
  
  int a[10][20];
   int m,n;
   srand(time(NULL));
   //User input
   printf("please enter number of columns and rows");
   scanf("%d %d", &amp;m,&amp;n);
   fillArray(a,m,n);
   printarray (a,m,n);
   printf("The smoothed image is\n");
   smooth(a,m,n);
   getch();
  return 0;
  }
  </code></pre>
  
  <p>right now if I entered 3 and 3 I would get something like this:</p>
  
  <pre><code>23 43 54
  12 76 89
  56 98 24
  
  The smoothed image is
  347373849493234343
  12 23345345345
  2132334565645645645
  </code></pre>
  
  <p>Anyone got any ideas?</p>