2d dft opencv. org and just adjust couple of lines to inverse.