Posts

Image Compression using Fast Fourier Transform(FFT)

  In [38]: import numpy as np import pandas as pd import matplotlib.pyplot as plt from matplotlib.image import imread import os In [44]: plt . rcParams [ 'figure.figsize' ] = [ 5 , 5 ] plt . rcParams . update ({ 'font.size' : 18 }) A = imread ( os . path . join ( 'afrc2016-0195-196.jpg' )) # Load Image B = np . mean ( A , - 1 ) # Conver RGB to grayscale plt . figure () plt . imshow ( 256 - A ) # cmap = 'gray_r' plt . axis ( 'off' ) <IPython.core.display.Javascript object> Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Out[44]: (-0.5, 6047.5, 4031.5, -0.5) In [45]: Bt = np . fft . fft2 ( B ) Btsort = np . sort ( np . abs ( Bt . reshape ( - 1 ))) # Sort by magnitude # Zero out all small coefficents and ...