title: Sharpening using Gaussian 3x3 filter works but the result is white pixels
body: <p>The following program is not working. I am implementing Gaussian 3x3 filter to sharpen the image file  <code>FACE DETECTION.png</code>, but the result is just showing white color. I think the value of sum is more than 255 in convolution operation. I need a solution...</p>
  
  <p>CODE:</p>
  
  <pre><code>int main()
  {
  
    Mat src, dst;
    float sum;
  
    /// Load an image
    src = imread("FACE DETECTION.png", 0);
  
    if( !src.data )
    { return -1; }
  
    // define the kernel
    float Kernel[3][3] = {
                          {1.0, 2.0, 1.0},
                          {2.0, 4.0, 2.0},
                          {1.0, 2.0, 1.0}
                         };
       dst = src.clone();
      for(int y = 0; y &lt; src.rows; y++)
          for(int x = 0; x &lt; src.cols; x++)
              dst.at&lt;uchar&gt;(y,x) = 0.0;
      //convolution operation
      for(int y = 1; y &lt; src.rows - 1; y++){
          for(int x = 1; x &lt; src.cols - 1; x++){
              sum = 0.0;
              for(int k = -1; k &lt;= 1;k++){
                  for(int j = -1; j &lt;=1; j++){
                      sum = sum + Kernel[j+1][k+1]*src.at&lt;uchar&gt;(y - j, x - k);
                      sum = sum&gt;255? 255:sum;
                      sum = sum&lt;0? 0:sum;
                  }
              }
              dst.at&lt;uchar&gt;(y,x) = sum;
          }
      }
  
  
      namedWindow("final");
      imshow("final", dst);
  
      namedWindow("initial");
      imshow("initial", src);
  
    waitKey();
  
  
  return 0;
  }
  </code></pre>