title: Value was either too large or too small for an Int32 when processing image
body: <p>Below is a part of my code where I am trying to apply an image filer to clear an image</p>
  
  <pre><code>       //Convert the image to integer array
          uint[,] image = new uint[use.Width, use.Height];
          for (i = 0; i &lt; use.Width; i++)
          {
              for (j = 0; j &lt; use.Height; j++)
              {
                  image[i, j] = Convert.ToUInt32(use.GetPixel(i, j).R);
              }
          }
  
          int Block = 5;
          int BlockSqr = 25;
  
          // Internal Block Processing
          for (i = Block; i &lt; use.Width- Block; i = i + 1)
              for (j = Block; j &lt; use.Height- Block; j = j + 1)
              {
                  int lM, lVAR;
  
                  // Calculating the Mean of the Block
                  tmp = 0;
                  for (int k = i - Block; k &lt; i + Block; k = k + 1)
                  {
                      for (int l = j - Block; l &lt; j + Block; l = l + 1)
                      {
                          tmp = tmp + image[k, l];
                      }
                  }
                  lM = Convert.ToInt32(Math.Abs(tmp / BlockSqr));
  
                  // Calculating the Variance of the Block
                  tmp = 0;
                  M1 = 0;
                  for (int k = i - Block; k &lt; Block + i; k = k + 1)
                  {
                      for (int l = j - Block; l &lt; Block + j; l = l + 1)
                      {
                          M1 = ((image[k, l] - Convert.ToUInt32(lM)) * (image[k, l] - Convert.ToUInt32(lM)));
                          tmp = tmp + M1;
                      }
                  }
                  lVAR = Convert.ToInt32(Math.Abs(tmp / BlockSqr));
  
                  //Putting the filtered value
  
                  float tm = (lVAR - mVAR);
                  float tm1 = tm / lVAR;
                  int mm = Convert.ToInt32(image[i, j] - lM);
                  float tm2 = tm1 * (image[i, j] - lM);
                  int A = lM + Convert.ToInt32(tm2);
  
                  if (A &lt; 255)
                      Wiener.SetPixel(i, j, Color.FromArgb(255, A, A, A));
  
              }
  </code></pre>
  
  <p>The problem is that I get the below error when i process the image</p>
  
  <blockquote>
    <p>Value was either too large or too small for an Int32.</p>
  </blockquote>
  
  <p>On </p>
  
  <blockquote>
    <p>int A = lM + Convert.ToInt32(tm2);</p>
  </blockquote>
  
  <p>Any idea what the problem is?</p>
  
  <p>edit: did some debugging</p>
  
  <p>lM hold 0 and lVAR hold 0</p>