function [Ilowpassed] = lowpassfilter(original_image,a)

% Call this functionm with: Ilow = lowpassfilter('Io.jpg',0.001);
I = imread(original_image);
I = double(I) ./ 255;
[rows,columns,colours] = size(I);
IF = zeros(rows,columns,colours);
for c = 1:1:colours
    Ic = I(:,:,c);
    Fc = fft2(Ic);
    Cc = sqrt(Fc .* conj(Fc));
    C = reshape(Cc,1,rows*columns);
    F = reshape(Fc,1,rows*columns);
    [~,IC] = sort(C,'ascend');
    L = length(C);
    Na = round(a*L);
    Is = L - Na + 1;
    If = L;
    Izeros = IC([Is:If]);
    F(Izeros) = 0;
    F = reshape(F,rows,columns);
    IFc = ifft2(F);
    IFc = real(IFc);
    IF(:,:,c) = IFc;
end
Ilowpassed = uint8(IF.*255);
imshow(Ilowpassed);