% Restoration: Remove bars from image

RGB = imread('JagFish.jpg');
image(RGB)
axis equal
R = RGB(:,:,1);
G = RGB(:,:,2);
B = RGB(:,:,3);


% Degrade, image:
Rb = double(R);
Gb = double(G);
Bb = double(B);

[mI, nI] = size(Gb);

Dist = 128*ones(mI,1)*(sin(1:nI)>0.7);
Gb = Gb + Dist;

RGB2 = RGB;
RGB2(:) = [Rb,Gb,Bb];	% Wierd trick!!
figure(1)
image(RGB2)

% Image restoration:
=======================

FRb = fft2(Rb);
FGb = fft2(Gb);
FBb = fft2(Bb);

figure(2)
image(sqrt(abs(FGb/8 )))
colormap gray

mesh(fftshift(abs(FGb )))

FGb(1,20:200) = 0;

FixedR = real(ifft2(FRb));
FixedG = real(ifft2(FGb));
FixedB = real(ifft2(FBb));

FixedRGB = uint8(zeros(mI,nI,3));
FixedRGB(:) = [FixedR,FixedG,FixedB];
figure(2)
image(FixedRGB)

imwrite(FixedRGB,'CaravRest.jpg','jpeg')  
imwrite(RGB2,'CaravDegraded.jpg','jpeg')     
 




