% Load image into matrix I.
I = imread('Io.jpg');
% Convert imgage intensity values from uint8 to double.
I = double(I);
% Normalize intensity values from [0..255] to [0..1] interval.
I = I / 255;
% Display original image.
figure('Name','Original Image');
imshow(I);

% Get Red Green and Blue Color Components.
IR = I(:,:,1);
IG = I(:,:,2);
IB = I(:,:,3);

% Get the Fourier Transform for each color component.
FR = fftshift(fft2(IR));
FG = fftshift(fft2(IG));
FB = fftshift(fft2(IB));

% Get the amplitude for the Fourier coefficients for each color component.
CR = sqrt(FR .* conj(FR));
CG = sqrt(FG .* conj(FG));
CB = sqrt(FB .* conj(FB));

% Convert Fourier coefficients into valid intensity values in the [0..255}
% range.
% x in [CRmin,CRmax] ==> x' in [0,1]
% CRmin <= x <= CRmax ==>
% 0 <= x - CRmin <= CRmax - CRmin ==> (CRmax <> CRmin)
%         x - CRmin
% 0 <= --------------- <= 1 ==> 0 <= x' <= 1
%        CRmax - CRmim
CRmin = min(min(CR));
CRmax = max(max(CR));
CGmin = min(min(CG));
CGmax = max(max(CG));
CBmin = min(min(CB));
CBmax = max(max(CB));

CR = (CR - CRmin) / (CRmax - CRmin);
CR = CR * 255;
CG = (CG - CGmin) / (CGmax - CGmin);
CG = CG * 255;
CB = (CB - CBmin) / (CBmax - CBmin);
CB = CB * 255;

% Display Fourier Transform for each color component.
figure('Name','Red Component Fourier Transform');
imshow(CR);
figure('Name','Green Component Fourier Transform');
imshow(CG);
figure('Name','Blue Component Fourier Transform');
imshow(CB);

% Compute Inverse Fourier Transform for each color component.
IFR = ifft2(ifftshift(FR));
IFG = ifft2(ifftshift(FG));
IFB = ifft2(ifftshift(FB));

% Compose the original image.
IF(:,:,1) = IFR;
IF(:,:,2) = IFG;
IF(:,:,3) = IFB;

% Display Inverse Fourier Transform.
figure('Name','Inverse Fourier Transform');
imshow(IF);