Inverse fourier transform

Hi every one.
I am a beginner in image processing using OpenCV. I interested to study when I get Fourier transform of an image, and then I want to go back from frequency domain to spatial domain what is the effect of phase on image when I change the phase. How can I change phase domain and with phase spectrum and magnitude spectrum get inverse Fourier transform? Any code may be helpful. Thanks.