Xzdc M.Sc.
(COMPUTER SCIENCE) SEMESTER - I
APPLIED SIGNAL AND IMAGE PROCESSING
Unit 1
FUNDAMENTALS OF DIGITAL SIGNALS PROCESSING
I. FUNDAMENTALS OF DIGITAL SIGNALS PROCESSING
A.What is Digital Signal Processing (DSP)?
1. DSP is a branch of engineering and applied mathematics that deals the
processing and analysis of digital signals
2. DSP is concerned with the numerical manipulation (treatment) of signals and
data in sampled form.
3. A wide variety of useful functions can be produced by using elementary
operations such as digital storage, addition, subtraction etc. by constants.
4. Basic DSP system:
5. Advantages and Disadvantages of DSP.
a) Advantages:
(1)DSP hardware is flexible and programmable
(2)DSP chips are relatively cheap (easily mass-produced)
(3)Digital storage is cheap
(4)Digital information can be encrypted, coded, and
compressed
b) Disadvantages:
(1)Sampling leads to loss of information
(2)High-resolution ultra-fast A/D and D/A may be expensive
(3)Digital processing cannot always be done in real-time
B.Periodic signals
1. Signals that repeat themselves after some period of time are called periodic
signals.
2. The shape of a periodic signal is called the waveform.
3. The duration to show three full repetitions of the signal known as cycles.
4. The duration of each cycle, called the period, is about 2.3 ms.
5. The number of cycles per second is called the frequency of the signal, it is the
inverse of the period.
6. The units of frequency are cycles per second, or Hertz, abbreviated “Hz”.
C.Spectral decomposition
1. Spectral decomposition is any signal that can be expressed as the sum of
sinusoids with different frequencies.
2. The discrete Fourier transform (DFT) produces the spectrum of a signal. The
spectrum of a signal is a set of sinusoids that add up to produce the signal.
D.Signals
1. A signal is defined as any physical quantity that varies with time, space, or any
other independent variable(s).
2. Signal processing is the process of operation in which the characteristics of a
signal such as Amplitude, shape, frequency, etc. undergoes a change.
3. To represent signals, the python module called thinkdsp.py provides a class
called signals.
4. Signals use_add_methode to add them and the result is a SumSignal, which
represent the sum of two or more signals:
a) mix = sin_sig + cos_sig
5. Frame- A Wave is a signal measured at different moments in time, with each
moment called a frame.
6. Framerate- Integral number of frames per second, which is also the number of
samples per second.
E.Spectrums
1. The system spectrum describes how the system changes signal magnitude
and phase as a function of frequency.
2. Wave provides make_spectrum, which returns a Spectrum:
spectrum = wave.make_spectrum()
3. And Spectrum provides plot: spectrum.plot()
4. Spectrum provides three methods that modify the spectrum:
a) low_pass applies a low-pass filter, which means that components above
a given cutoff frequency are attenuated (that is, reduced in magnitude)
by a factor.
b) high_pass applies a high-pass filter, which means that it attenuates
components below the cutoff.
c) band_stop attenuates components in the band of frequencies between
two cutoffs.
5. This example attenuates all frequencies above 600 by 99%:
spectrum.low_pass(cutoff=600, factor=0.01)
II. NOISE
A.Uncorrelated noise
1. The simplest kind of noise that can be generated is uncorrelated uniform noise
(UU) noise.
a) “Uniform” means the signal contains random values from uniform
distribution.
b) “Uncorrelated” means that the values are independent.
2. Distribution: The distribution of a random signal is the set of possible values
and their probabilities.
3. Gaussian noise is where the set of values is the range from negative to
positive infinity, but values near 0 are the most likely, with probability that
drops off according to the Gaussian or “bell” curve.
4. Correlation: Each value in UU noise is independent.
5. Brownian noise: is where each value is the sum of the previous value and a
random “step”.
6. Pink noise: is where power is inversely related to frequency.
B.Brownian noise
1. Here is a class definition that implements this algorithm:
a) class BrownianNoise(_Noise):
def evaluate(self, ts):
dys = np.random.uniform(-1, 1, len(ts))
ys = np.cumsum(dys)
ys = normalize(unbias(ys), self.amp)
return ys
2. Where, evaluate uses np.random.uniform to generate an uncorrelated signal
and np.cumsum to compute their cumulative sum.
3. Here’s the code that generates a BrownianNoise object and plots the
waveform.
a) signal = thinkdsp.BrownianNoise()
wave = signal.make_wave(duration=0.5, framerate=11025)
wave.plot()
4. #class Spectrum
a) def estimate_slope(self):
x = np.log(self.fs[1:])
y = np.log(self.power[1:])
t = scipy.stats.linregress(x,y)
return t
5. The first component of the spectrum is discarded because it corresponds to
f=0, and log0 is undefined.
6. The estimate_slope function gives results from scipy.stats.linregress, including
the slope, intercept, coefficient of determination (R2), the p-value, and
standard error.
7. For Brownian noise, the slope of the power spectrum is -2. Hence, we can
write:
a) log P = k − 2 log f
where,
P is power,
f is frequency
k is the intercept of the line
8. Exponentiating both sides yields:
a) P = K/f2
where,
K is ek
C.Pink Noise
1. For red noise, the relationship between frequency and power is
a) P = K/f2
2. We can synthesize noise with any exponent, β.
a) P = K/fβ
3. When β is between 0 and 2, the result is between white and red noise,
so it is called pink noise.
4. thinkdsp provides a class that represents a pink noise signal:
a) class PinkNoise(_Noise):
def __init__(self, amp=1.0, beta=1.0):
self.amp = amp
self.beta = beta
Where,
amp is the desired amplitude of the signal.
beta is the desired exponent.
5. PinkNoise provides make_wave, which generates a Wave.
a) def make_wave(self, duration=1, start=0, framerate=11025):
signal = UncorrelatedUniformNoise()
wave = signal.make_wave(duration, start, framerate)
spectrum = wave.make_spectrum()
spectrum.pink_filter(beta=self.beta)
wave2 = spectrum.make_wave()
wave2.unbias()
wave2.normalize(self.amp)
return wave2
b) Where,
duration is the length of the wave in seconds. start is the start
time of the wave; it is included so that make_wave has the same
interface for all types of signal, but for random noise, start time is
irrelevant. And framerate is the number of samples per second.
III. AUTOCORRELATION
A.Correlation
1. For two variables, x and y, that each contain N values:
a)
Where,
μx and μy are the means of x and y, and
σx and σy are their standard deviations.
2. Pearson’s correlation is always between -1 and +1 (including both).
a) If ρ is positive, we say that the correlation is positive, which means that
when one variable is high, the other tends to be high.
b) If ρ is negative, the correlation is negative, so when one variable is high,
the other tends to be low.
3. The magnitude of ρ indicates the strength of the correlation.
a) If ρ is 1 or -1, the variables are perfectly correlated, which means that if
you know one, you can make a perfect prediction about the other.
b) If ρ is near zero, the correlation is probably weak, so if you know one, it
doesn’t tell you much about the others.
4. First, define a function that constructs sine waves with different phase offsets:
def make_sine(offset):
signal = thinkdsp.SinSignal(freq=440, offset=offset)
wave = signal.make_wave(duration=0.5, framerate=10000)
return wave
5. Next, instantiate two waves with different offsets:
wave1 = make_sine(offset=0)
wave2 = make_sine(offset=1)
B.Serial correlation
1. Used in statistics to describe the relationship between observation of the
same variable over a specific period. If a variable serial correlation is
measured as a zero there is no correlation and each of the observations is
independent of one another.
2. To compute serial correlation, we can shift a signal and then compute the
correlation of the shifted version with the original.
a) def serial_corr(wave, lag=1):
n = len(wave)
y1 = wave.ys[lag:]
y2 = wave.ys[:n-lag]
corr = np.corrcoef(y1, y2, ddof=0)[0, 1]
return corr
C.Autocorrelation
1. serial_corr can be thought of as a function that maps from each value of lag to
the corresponding correlation, and we can evaluate that function by looping
through values of lag: def autocorr(wave):
lags = range(len(wave.ys)//2)
corrs = [serial_corr(wave, lag) for lag in lags]
return lags, corrs
D.Correlation as a dot product
1. The definition of Pearson’s correlation coefficient:
2. The definition of ρ simplifies to:
3. And it is common to simplify even further:
4. This definition of correlation is not “standardized”, so it doesn’t generally fall
between -1 and 1.
5. The dot product indicates the degree to which the signals are similar. If
they are normalized so their standard deviations are 1,
x · y = cos θ
where θ is the angle between the vectors.
2 FUNDAMENTALS OF DIGITAL SIGNALS PROCESSING - II
I. FREQUENCY DOMAIN OPERATIONS
A.Introduction to Frequency domain:
1. Frequency domain analysis and Fourier transforms are a cornerstone
of signal and system analysis.
2. It can be pictorially viewed as
B.Representing Image as Signals
1. Fourier series: Any function that periodically repeats itself can be expressed as
the sum of sines and/or cosines of different frequencies, each multiplied by a
different coefficient.
2. Fourier transform: Even functions that are not periodic (but whose area under
the curve is finite) can be expressed as the integral of sines and/or cosines
multiplied by a weighting function.
3. The frequency domain: refers to the plane of the two dimensional discrete
Fourier transform of an image.
C.FUNDAMENTAL STEPS IN DIGITAL IMAGE PROCESSING
The two broad categories are:
1. methods whose input and output are images, and
2. methods whose inputs may be images, but whose outputs are attributes
extracted from those images.
3. Image acquisition
a) It is the first process in digital image processing.
b) Acquisition could be as simple as being given an image that is already in
digital form.
c) Generally, the image acquisition stage involves preprocessing, such as
Scaling.
4. Image enhancement: The process of improving the quality of an image to make
it more useful
5. Image restoration: The process of recovering a high-quality image from a
degraded or noisy image.
6. Color image processing: The process of enhancing and manipulating images
that contain data from the visible spectrum.
7. Wavelets: Wavelet processing is a method that uses wavelets to break down
signals.
8. Compression: a process that reduces the size of an image file without
significantly degrading its quality.
a) It is familiar (perhaps inadvertently) to most users of computers in the
form of image file extensions, such as the jpg file extension used in the
JPEG (Joint Photographic Experts Group) image compression standard.
9. Morphological processing: a set of image processing techniques that analyze
and alter images based on their structure and shape.
10. Segmentation: the process of dividing something into smaller parts or
segments.
11. Feature extraction:
a) Feature extraction consists of feature detection and feature description.
b) Feature detection refers to finding the features in an image, region, or
boundary.
c) Feature description assigns quantitative attributes to the detected
Features.
12. Image pattern classification: It is the process that assigns a label (e.g.,
“vehicle”) to an object based on its feature descriptors.
D. Sampling and Fourier Transforms:
1. SAMPLING
the process of reducing a continuous-time (CT) signal to a discrete-time
(DT) signal
2.One way to model sampling is to multiply f (t ) by a sampling function equal to a
train of impulses ΔT units apart.
That is,
where f (t) denotes the sampled function.
3. Each component of this summation is an impulse weighted by the value of f (t ) at
the location of the impulse, as the above formula shows.
4. The value of each sample is given by the “strength” of the weighted impulse,
which we obtain by integration. That is, the value, fk , of an arbitrary sample in
the sampled sequence is given by
where we used the sifting property of .
E.The Fourier Transform of Sampled Functions
1. The fourier transform of sampled functions
a) Where,
F. DISCRETE FOURIER TRANSFORM
A mathematical technique that converts a sequence of numbers into
another sequence of numbers.
G.Convolution and Frequency Domain Filtering
1. CONVOLUTION:
a) The convolution of these two functions, denoted as before by the
operator , is defined as
2. We are interested in finding the Fourier transform:
3. The term inside the brackets is the Fourier transform of h(t − ).
a) We will show,
where H( ) m is the Fourier transform of h (t ).
b) Using this in the preceding equation gives us
where “ . ” indicates multiplication.