title: I want to find the fourier spectrum of an image
body: <p>Is this correct? <code>p1</code> is the source image and <code>p2</code> the destination image and all the 3 channels have the same value as I am working with grayscale image and <code>pp1[i]</code> accesses the 'ith' channel.</p>
  
  <pre><code>for(int x=0;x&lt;height;x++)
  {
      for(int y=0;y&lt;width;y++)
      {
          pp1=pixel1+x*rowstride+y*n_channels;
          pp2=pixel2+x*rowstride+y*n_channels;
          for(int xx=0;xx&lt;height;xx++)
          {
              for(int yy=0;yy&lt;width;yy++)
              {
                  real=real+pp1[0]*cos(2*3.14*yy*y/width+2*3.14*xx*x/height);
                  imag=imag-pp1[0]*sin(2*3.14*yy*y/width+2*3.14*xx*x/height);
              }
          }
          temp=sqrt(real*real+imag*imag);
  
          pp2[0]=(int)temp;
          pp2[1]=(int)temp;
          pp2[2]=(int)temp;
      }
  }
  </code></pre>