%"Compresses" a grayscale image by thresholding its Fourier coefficients.
%The threshold can either be a scalar or a vector (in which case each coefficient is
%thresholded according to its corresponding vector element).

function [outImg] = compressImg(inImg, threshold)
    warning('OFF', 'Images:isrgb:obsoleteFunction');
    
    if (isrgb(inImg))
        inImg = rgb2gray(inImg);
    end
    
    fimg = fft2(im2double(inImg));
    outImg = ifft2(fimg .* (abs(fimg) > threshold));
end
