Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

# This is for FFT # we are going to use matplotlib image package and import the image read so that we can load our image dog.jpg from matplotlib.image import imread #for reading the functions import...

1 answer below »
# This is for FFT
# we are going to use matplotlib image package and import the image read so that we can load our image dog.jpg
from matplotlib.image import imread #for reading the functions
import numpy as np #by using mathematical and logical operations on a
ays can be performed.
import matplotlib.pyplot as plt #this is a state-based interface to matplotlib. It provides a MATLAB-like way of plotting.pyplot is mainly intended for interactive plots and simple cases of programmatic plot generation:
import os
plt.rcParams['figure.figsize'] = [5, 5]
plt.rcParams.update({'font.size': 18})
#reading an image by using imread funtion
A=imread(os.path.join('/content/drive/MyDrive/dog.jpg'))
B = np.mean(A, -1)
#crearting a figure
plt.figure()#The figure() function in pyplot module of matplotlib li
ary is used to create a new figure.
#showing the image
plt.imshow(256-A)#The imshow() function in pyplot module of matplotlib li
ary is used to display data as an image
plt.axis('off')#The plt. axis() method allows you to set the x and y limits with a single call,
Bt=np.fft.fft2(B)
#sorting a
ay
Btsort = np.sort(np.abs(Bt.reshape(-1)))
for keep in(0.1,0.05,0.01,0.002):
thresh =Btsort[int(np.floor((1-keep)*len(Btsort)))]
ind = np.abs(Bt)>thresh
Btlow=Bt*ind
Alow = np.fft.ifft2(Btlow).real
plt.figure()
plt.imshow(256-Alow,cmap='gray')
plt.axis('off')
plt.title('Compressed image: keep = ' + str(keep*100) + '%')
****************************************************************************
****************************************************************************
****************************************************************************
# This is for Wavelet Transform
from matplotlib.image import imread
import numpy as np
import matplotlib.pyplot as plt##this is a state-based interface to matplotlib. It provides a MATLAB-like way of plotting.pyplot is mainly intended for interactive plots and simple cases of programmatic plot generation:
import os
import pywt#this is a scientific Python module for Wavelet Transform calculations.
#changing the size of an image
plt.rcParams['figure.figsize'] = [16, 16]
#changing the font size
plt.rcParams.update({'font.size': 18})
#reading the image using imread image
A=imread(os.path.join('/content/drive/MyDrive/dog.jpg'))
#taking average
B = np.mean(A, -1)
n=2
w='db1'
#using pywt.wavedec2 for multilevel decomposition
coeffs = pywt.wavedec2(B, wavelet=w, level=n)
coeffs[0] /= np.abs(coeffs[0]).max()
for detail_level in range(n):
coeffs[detail_level + 1] = [d/np.abs(d).max() for d in coeffs[detail_level + 1]]
a
, coeff_slices= pywt.coeffs_to_a
ay(coeffs)
plt.imshow(a
, cmap='gray_r',vmin=-0.25,vmax=0.75)
#again changing the figure size
plt.rcParams['figure.figsize'] = [16, 16]
fig=plt.figure(figsize=(18, 16))
plt.show()
Answered 1 days After Nov 03, 2021

Solution

Aparna answered on Nov 04 2021
125 Votes
PowerPoint Presentation
Image Compression Using
Fourier Transform & Wavelet Transform
OBJECTIVES
1.
Fourier Transform
2.
Wavelet Transform
4.
Image Compression by Fourier Transform
5.
Image Compression by Wavelet Transform
3.
Image Compression
6.
Comparison
7.
References
1. Fourier Transform
In the year 1807, Joseph Fourier presented Fourier series, which could express any function as linear combination of harmonically related sinusoids or periodic exponentials.
Later, Fourier gave representation of non-periodic signals as weighted integral of sinusoids. This representation is known as Fourier transform.
Fourier transform (FT) is an integral transform that represents a signal or a function in terms of sinusoids. It is a mathematical tool used for frequency analysis of signals.
Commonly used to transform a function in the time domain to the frequency domain.
Mathematical representation
The Fourier transform of a function is given by
and its inversion is given by
Fourier transform decomposes the signal in infinite number of sine or cosine waves
(1.1)
(1.2)
Discrete Fourier Transform (DFT)
DFT calculates Fourier transform on a discrete set of frequencies from a discrete set of time samples.
Discrete Fourier transform of a signal is given by
and its inversion is given by
x.
Where k is index of discrete frequencies and n is the index of the time samples.
(1.3)
(1.4)
There is no essential difference between FFT and DFT in the fact that they both ca
y out Fourier transform on discrete signals. FFT was introduced to reduce the computational complexity involved in DFT.
The complexity of the DFT algorithm is O(n 2 ) while FFT has a complexity of O(n · log n).
For a 1024 point transform (N=1024), this will give approximately a 100 fold speed improvement.
Fast Fourier Transform (FFT)
where is a periodic function with only distinct values and its inversion is given by
(1.5)
(1.6)
FFT is given by
Block Diagram of FFT
Different FFT Algorithms
Fast Fourier Transform
Cooley Tukey Algorithm
Radix-2 Decimation Algorithm
Radix-4 Algorithm
Split Radix Algorithm
Fast Hartley Transform
Quick Fourier Transform
Data compression of digitized signals.
Audio waves sampled digitally.
Eliminate frequencies with values under a certain threshold by truncating small FFT.
Used for digital frequency filtering.
Magnetic Resonance Imaging
Few applications of FFT
How wavelets came into existence?
FT expresses the data or signals as a sum of sine waves which are not localized in time or space. Hence, these sine waves oscillate endlessly.
Fourier Transform oscillating endlessly
Wavelet
Therefore, new sets of functions were needed that can precisely analyse the signals...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here