img=Import["ExampleData/lena.tif"]; Image[img,ImageSize->300]
ImageDimensions[img]
{150,116}
(*see how many channels*) ImageChannels[img]
3
data=ImageData[img]; (*get data*) {nRow,nCol,nChannel}=Dimensions[data]
{116,150,3}
(*look at each channel*) Map[Image[data[[All,All,#]],ImageSize->100]&, Range[1,nChannel]]
(*get channel 2 to FFT but center it first*) d = data[[All,All,2]]; d = d*(-1)^Table[i+j,{i,nRow},{j,nCol}]; (*make FFT,center, view spectrum and phase*) fw = Fourier[d,FourierParameters->{1,1}]; (*adjust for better viewing as needed*) fudgeFactor = 100; abs = fudgeFactor * Log[1+Abs@fw]; Labeled[Image[abs/Max[abs], ImageSize->300], Style["Magnitude spectrum", 18]]
arg = Arg@fw; Labeled[Image[arg/Max[arg], ImageSize->300], Style["Phase spectrum", 18]]
close all; clear all; %image in same folder. img = imread('lena.tiff','tif'); imagesc(img)
img = fftshift(img(:,:,2)); F = fft2(img); figure; imagesc(100*log(1+abs(fftshift(F)))); colormap(gray); title('magnitude spectrum');
figure; imagesc(angle(F)); colormap(gray); title('phase spectrum');