You are on page 1of 23

07-11-2020

Unit- IV

18CSE353T - Digital Image Processing


Dr. R. Rajkamal

11/7/2020 Dr. R. Rajkamal 1

Wavelets
Unlike the Fourier transform, whose basis functions are sinusoids, wavelet
transforms are based on small waves, called wavelets, of varying frequency
and limited duration.

An image pyramid A simple system for creating approximation


and prediction residual pyramids.
Dr. R. Rajkamal

1
07-11-2020

Wavelets

 Upsampling can be thought of as inserting a 0 after


every sample in a sequence;

 downsampling can be viewed as discarding every other


sample

Dr. R. Rajkamal

Subband Coding
 In subband coding, an image is decomposed into a set of bandlimited components,
called subbands.

 The decomposition is performed so that the subbands can be reassembled to


reconstruct the original image without error.

Dr. R. Rajkamal

2
07-11-2020

Subband Coding

The analysis filter bank, which includes filters h0(n) and h1(n), is used to break input
sequence f(n) into two half length sequences flp(n) and fhp(n) the subbands that represent
the input.

Dr. R. Rajkamal

Fourier versus Wavelets FFT Vs Wavelet


• Fourier • FFT, basis functions: sinusoids
– Loses time (location) coordinate completely • Wavelet transforms: small waves, called wavelet
– Analyses the whole signal
– Short pieces lose “frequency” meaning • FFT can only offer frequency information

• Wavelet: frequency + temporal information


• Wavelets • Fourier analysis doesn’t work well on discontinuous, “bursty”
– Localized time-frequency analysis
data
– Short signal pieces also have significance
– -- music, video, power, earthquakes,…
– Scale = Frequency band

Dr. R. Rajkamal

3
07-11-2020

Wavelet Definition
“The wavelet transform is a tool that cuts up data, functions or operators into different
frequency components, and then studies each component with a resolution matched to
its scale”

• Dr. Ingrid Daubechies, Lucent, Princeton U

Dr. R. Rajkamal

scaling
• It lets you either narrow down the frequency band of interest, or
determine the frequency content in a narrower time interval
• Scaling = frequency band
• Good for non-stationary data
• Low scalea Compressed wavelet Rapidly changing
detailsHigh frequency .
• High scale a Stretched wavelet  Slowly changing, coarse
features  Low frequency

Dr. R. Rajkamal

4
07-11-2020

Continuous Wavelet Transform


1. Take a wavelet and compare it to a section at the start of the original signal.

2. Calculate a correlation coefficient c

3. Shift the wavelet to the right and repeat steps 1 and 2 until you've covered the whole

signal.
Small scale
-Rapidly changing details,
4. Scale (stretch) the wavelet and repeat steps 1 through 3. -Like high frequency

Large scale
5. Repeat steps 1 through 4 for all scales. -Slowly changing
details
-Like low frequency

Dr. R. Rajkamal

Discrete Wavelet Transform


• “Subset” of scale and position based on
power of two Signal
– rather than every “possible” set of
scale and position in continuous LOWPASS HIGHPASS
wavelet transform
Filters
• Behaves like a filter bank: signal in,
coefficients out
Approximation Details
• Down-sampling necessary (twice as (A) (D)
much data as original signal)

Dr. R. Rajkamal

5
07-11-2020

Haar Transform
Haar transform, separable and symmetric

T = HFH where F is an NN image matrix


H is NN transformation matrix,  1
1 if 0  t  2
H 1 (t )  
1
  1 if
 2
 n ( n  0 .5 )
 2 p for  t 
H contains the Haar basis functions, hk(z) 2 p
2p
 ( n  0 .5 ) ( n  1)
H0(t) = 1 for 0  t < 1 H ( t )    2 p for  t 
2p n p
 2 2p
 0 otherwise

whereP  1 , 2 , 3 ,... andn  0 ,1 ,..., 2 p  1

Dr. R. Rajkamal

Multi Resolution Expansion


In MRA (multi resolution analysis),
• scaling function to create a series of approximations of a function or image,
• wavelet to encode the difference in information between different
approximations.
• A signal or function f(x) can be analyzed as a linear combination of expansion
functions
f (x)   k
k k

 k  exp ansioncoef ficients


 k ( x )  basisfunct ion
Dr. R. Rajkamal

6
07-11-2020

Haar Scaling Function


Set {j,k(x)} where,  j ,k (x)  2 j/2
 ( 2 j x  k ) forallj , k  Z

K determines the position of j,k(x)


along the x-axis, j -- j,k(x) width,
and 2j/2—height or amplitude

The shape of j,k(x) change with j,


(x) is called scaling function

Dr. R. Rajkamal

Fundamental Requirements of MRA


MRA Requirement 1: The scaling function is orthogonal to its integer translates.
This is easy to see in the case of the Haar function, because whenever it has a
value of 1, its integer translates are 0, so that the product of the two is 0. The
Haar scaling function is said to have compact support, which means that it is 0
everywhere outside a finite interval called the support.

MRA Requirement 2: The subspaces spanned by the scaling function at low


scales are nested within those spanned at higher scales.

MRA Requirement 3: The only function that is common to all Vj is f(x) = 0

MRA Requirement 4: Any function can be represented with arbitrary precision

Dr. R. Rajkamal

7
07-11-2020

Multi Resolution Expansion

Dr. R. Rajkamal

Applications of wavelets
• Pattern recognition
– Biotech: to distinguish the normal from the pathological membranes
– Biometrics: facial/corneal/fingerprint recognition
• Feature extraction
– Metallurgy: characterization of rough surfaces
• Trend detection:
– Finance: exploring variation of stock prices
• Perfect reconstruction
– Communications: wireless channel signals
• Video compression – JPEG 2000

Dr. R. Rajkamal

8
07-11-2020

Fundamentals of Compression
• To better understand the need for compact image representations, consider
the amount of data required to represent a two-hour standard definition
(SD) television movie using 720 x 480 x 24 bit pixel arrays.
• A digital movie (or video) is a sequence of video frames in which each frame
is a full-color still image.
• Because video players must display the frames sequentially at rates near 30
fps (frames per second), SD digital video data must be accessed at

Dr. R. Rajkamal

Fundamentals of Compression
• 224 GB (gigabytes) of data.
• Twenty-seven 8.5 GB dual-layer DVDs (assuming conventional 12 cm disks) are needed to
store it.
• To put a two-hour movie on a single DVD, each frame must be compressed—on average—
by a factor of 26.3.
• The compression must be even higher for high definition (HD) television, where image
resolutions reach 1920 * 1080 * 24 bits/image.
The term data compression refers to the process of reducing the amount of
data required to represent a given quantity of information.
Data and information are not the same thing;
various amounts of data can be used to represent the same amount of
information, representations that contain irrelevant or repeated information
are said to contain redundant data.
Dr. R. Rajkamal

9
07-11-2020

Fundamentals of Compression
Types of data redundancies
1. Coding redundancy.
• Each piece of information or event is assigned a sequence of code symbols, called a code word.
• The number of symbols in each code word is its length.
• The 8-bit codes that are used to represent the intensities in most 2-D intensity arrays contain
more bits than are needed to represent the intensities.
2. Spatial and temporal redundancy.
• Because the pixels of most 2-D intensity arrays are correlated spatially (i.e., each pixel is similar
to or dependent on neighboring pixels), information is unnecessarily replicated in the
representations of the correlated pixels.
• In a video sequence, temporally correlated pixels (i.e., those similar to or dependent on pixels in
nearby frames) also duplicate information.
3. Irrelevant information.
• Most 2-D intensity arrays contain information that is ignored by the human visual system and/or
extraneous to the intended use of the image. It is redundant in the sense that it is not used.
Dr. R. Rajkamal

Fundamentals of Compression
Example:
Compression Ratio: original image = 256 x 256 pixels,
Single band (gray-scale) 8 bits/pixel = file is 65536 bytes (64K)
Compression Ratio = Uncompressed file size after compression image file = 6554 bytes
Compressed file size Compression Ratio= 10 => 10:1 => 10 to 1 compression
=> 10 times compression
i.e. image has been compressed to 1/10 original size

Compression Factor = Size before compression / Size after compression


Compression Factor is reverse of compression ratio

Saving % = Size before – Size after / Size before


This shows shrinkage
Redundancy = 1 – (1 / Compression Ratio)

Fidelity Criteria (1) objective fidelity criteria and (2) subjective fidelity criteria.
Dr. R. Rajkamal

10
07-11-2020

Image Compression
 The encoder performs
compression, and the decoder
performs the complementary
operation of decompression.
 Both operations can be
performed in software, as is the
case in Web browsers and many
commercial image editing
programs, or in a combination of
hardware and firmware, as in
commercial DVD players.
 A codec is a device or program
that is capable of both encoding
and decoding.

Dr. R. Rajkamal

Image Compression
Compression Decompression
Data Reduction
- reduce image data by gray-level and/or spatial quantization,
or can undergo any desired image enhancement (e.g. noise Decoding
removal ) process.
- takes the compressed file and reverses the
Mapping original coding by mapping the
- maps the original data into another mathematical space codes to the original, quantized values.
where it is easier to compress the data. Inverse Mapping
Quantization - reverse the original mapping process.
- It takes the potentially continuous data from the mapping Postprocessing
stage and puts it in discrete form.
- This operation is irreversible, so must be omitted if error- - enhance the look of the final image.
free compression is desired.

Coding
- maps the discrete data from the quantizer onto a code in an
optimal manner. Dr. R. Rajkamal

11
07-11-2020

Image Compression Formats


• The entries in black are international standards
sanctioned by the International Standards
Organization (ISO), the International
Electrotechnical Commission (IEC), and/or the
International Telecommunications Union (ITU-
T)—a United Nations (UN) organization that
was once called the Consultative Committee of
the International Telephone and Telegraph
(CCITT).

• Two video compression standards, VC-1 by the


Society of Motion Pictures and Television
Engineers (SMPTE) and AVS by the Chinese
Ministry of Information Industry (MII), are also
included.

Dr. R. Rajkamal

Image Compression
 Data ( Text, Graphics, Still Images and Video Animation, Sounds)compression is the process of
encoding data so that it takes less storage space or less transmission time than it would if it were
not compressed.
 The fundamental task of image compression is to reduce the amount of data required to
represent the image. This is done by transforming and removing image data redundancies.
 There are two major categories of compression algorithms:
• Lossless compression algorithms
• Lossy compression algorithms
Why Compression ?
To reduce the volume of data to be transmitted (text, fax, images)
To reduce the bandwidth required for transmission and to reduce storage requirements (speech, audio, video)
Dr. R. Rajkamal

12
07-11-2020

Image Compression
 Lossy compression algorithms
 The original data is reconstructed perfectly
 Theoretical limit on maximal compression
 Practical compression ratios of <10 : 1 (still images)

Example techniques: Huffman coding, Arithmetic coding, Shanon Fano coding

 Lossless compression
 lossless compression for legal and medical documents, computer programs
 exploit only code and inter-pixel redundancy

Example technique: Linear prediction, transform coding

Dr. R. Rajkamal

Huffman coding

 One of the most popular techniques for removing coding redundancy is due to Huffman
(Huffman [1952]).

 When coding the symbols of an information source individually, Huffman coding yields the
smallest possible number of code symbols per source symbol.

 In practice, the source symbols may be either the intensities of an image or the output of an
intensity mapping operation (pixel differences, run lengths, and so on).

Dr. R. Rajkamal

13
07-11-2020

Huffman coding First step


 The first step in Huffman’s approach is to create a series of
source reductions by ordering the probabilities of the symbols
under consideration and combining the lowest probability
symbols into a single symbol that replaces them in the next
source reduction.

 At the far left, a hypothetical set of source symbols and their probabilities are ordered from top to bottom
in terms of decreasing probability values.
 To form the first source reduction, the bottom two probabilities, 0.06 and 0.04, are combined to form a
“compound symbol” with probability 0.1.
 This compound symbol and its associated probability are placed in the first source reduction column so that
the probabilities of the reduced source also are ordered from the most to the least probable.
 This process is then repeated until a reduced source with two symbols (at the far right) is reached.
Dr. R. Rajkamal

Huffman coding

Dr. R. Rajkamal

14
07-11-2020

Huffman coding
Second step
 The in Huffman’s procedure is to code each reduced
source, starting with the smallest source and working
back to the original source.
 The minimal length binary code for a two-symbol source,
of course, are the symbols 0 and 1.

 Symbols are assigned to the two symbols on the right (the assignment is arbitrary; reversing the order of
the 0 and 1 would work just as well).
 As the reduced source symbol with probability 0.6 was generated by combining two symbols in the reduced
source to its left, the 0 used to code it is now assigned to both of these symbols, and a 0 and 1 are arbitrarily
appended to each to distinguish them from each other.
 This operation is then repeated for each reduced source until the original source is reached.
 The final code appears at the far left.
Dr. R. Rajkamal

Huffman coding
The average length of this code is

 Huffman’s procedure creates the optimal code for a set of symbols and probabilities subject to the constraint
that the symbols be coded one at a time.
 After the code has been created, coding and/or error-free decoding is accomplished in a simple lookup table
manner. The code itself is an instantaneous uniquely decodable block code.
 It is called a block code because each source symbol is mapped into a fixed sequence of code symbols.
 It is instantaneous because each code word in a string of code symbols can be decoded without referencing
succeeding symbols. It is uniquely decodable because any string of code symbols can be decoded in only one
way.

Dr. R. Rajkamal

15
07-11-2020

Huffman coding

Dr. R. Rajkamal

Huffman coding

Dr. R. Rajkamal

16
07-11-2020

Run Length Coding

Vertical Scanning

Dr. R. Rajkamal

Shannon- Fano Coding

Dr. R. Rajkamal

17
07-11-2020

Arithmetic coding
 Arithmetic coding generates nonblock codes.
 an entire sequence of source symbols (or message) is assigned a single arithmetic code word.
 The code word itself defines an interval of real numbers between 0 and 1.
 Each symbol of the message reduces the size of the interval in accordance with its probability of
occurrence. Because the technique does not require, as does Huffman’s approach, that each source symbol
translate into an integral number of code symbols (that is, that the symbols be coded one at a time), it
achieves (but only in theory) the bound established by Shannon’s first theorem

More information creates a lower measure of entropy. Less information creates a higher measure of entropy.

Dr. R. Rajkamal

Arithmetic coding

 As the length of the sequence being


coded increases, the resulting
arithmetic code approaches the
bound established by Shannon’s first
theorem.
In practice, two factors cause coding performance to fall short of the bound:
(1) the addition of the end-of-message indicator that is needed to separate one message from another; and
(2) the use of finite precision arithmetic
Dr. R. Rajkamal

18
07-11-2020

LZW algorithm
 The LZW algorithm is a very common compression technique.
 This algorithm is typically used in GIF and optionally in PDF and TIFF.
 It is lossless, meaning no data is lost when compressing.
 The algorithm is simple to implement and has the potential for very high
throughput in hardware implementations.
 It is the algorithm of the widely used Unix file compression utility compress,
and is used in the GIF image format.

Dr. R. Rajkamal

LZW algorithm

Dr. R. Rajkamal

19
07-11-2020

LZW algorithm

LZW compression works by


 reading a sequence of symbols,
 grouping the symbols into strings, and
 converting the strings into codes.
Because the codes take up less space than the strings
they replace, we get compression.

Dr. R. Rajkamal

LZW algorithm
Characteristic features of LZW includes,
 LZW compression uses a code table, with 4096 as a common choice for the number of table entries.
 Codes 0-255 in the code table are always assigned to represent single bytes from the input file.
 When encoding begins the code table contains only the first 256 entries, with the remainder of the
table being blanks. Compression is achieved by using codes 256 through 4095 to represent sequences
of bytes.
 As the encoding continues, LZW identifies repeated sequences in the data, and adds them to the
code table.
 Decoding is achieved by taking each code from the compressed file and translating it through the code
table to find what character or characters it represents.

Dr. R. Rajkamal

20
07-11-2020

Transform Coding

Dr. R. Rajkamal

Transform selection
 Block transform coding systems based on a variety of discrete 2-D transforms have been
constructed and/or studied extensively.
 The choice of a particular transform in a given application depends on the amount of
reconstruction error that can be tolerated and the computational resources available.
 Compression is achieved during the quantization of the transformed coefficients.

r(x, y, u, v) s(x, y, u, v) are called the forward and inverse transformation kernels

Dr. R. Rajkamal

21
07-11-2020

JPEG compression
 JPEG stands for Joint photographic experts group. It is the first international standard in
image compression.
 It could be lossy as well as lossless .
 But the technique taken for discussion is lossy compression technique.
First step is to divide an image into blocks with each having dimensions of 8 x8.

Dr. R. Rajkamal

JPEG compression
 The range of the pixels intensities now are from 0 to 255. We will change the range from -
128 to 127.
 Subtracting 128 from each pixel value yields pixel value from -128 to 127. After subtracting
128 from each of the pixel value, we got the following results.

 The result comes from this is stored in let’s


say A(j,k) matrix.

Dr. R. Rajkamal

22
07-11-2020

JPEG compression
 There is a standard matrix that is used for computing JPEG compression, which is given by
a matrix called as Luminance matrix.
 This matrix is

Applying the following formula

Dr. R. Rajkamal

23

You might also like