0% found this document useful (0 votes)
155 views29 pages

Move To Front Encoding and Decoding

Move-to-front encoding is a data compression technique that restructures data to make it more compressible. It works by maintaining a list of all possible characters, outputting the position of each input character in the list, and then moving that character to the front. This tends to generate runs of small numbers if characters are repeated, improving compressibility. Decoding uses the same list and moves characters back to reconstruct the original data.

Uploaded by

Flask Tutorial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
155 views29 pages

Move To Front Encoding and Decoding

Move-to-front encoding is a data compression technique that restructures data to make it more compressible. It works by maintaining a list of all possible characters, outputting the position of each input character in the list, and then moving that character to the front. This tends to generate runs of small numbers if characters are repeated, improving compressibility. Decoding uses the same list and moves characters back to reconstruct the original data.

Uploaded by

Flask Tutorial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Data Compression (RCS087)

Move-To-Front Encoding

Prepared By:
Dr. Swati Singh
Assistant Professor, CSE Deptt
IMS Engineering College, Ghaziabad
DR. A. P. J. ABDUL KALAM TECHNICAL UNIVERSITY, Uttar
Pradesh
Need of Move-To-Front Encoding
 Move-to-Front encoding, takes input as string and gives output as a s
numbers, one for each character in the input string.
 If the input string has lots of sequences containing the same letter in a
then the output series will have a lot of small values.
 This means: If we have an input string with lots of sequences containi
same letter in a row, then we can first apply Move-to-Front encoding.
 This gives us a new series which contains lots of small numbers.
 Then we can apply any encoding, in which we choose to use less spac
small numbers than on bigger numbers.
 The end result should then be a shorter sequence than the original one
Move-To-Front Encoding
 The MTF (Move to Front) is a data transformation algorithm that
restructures data in such a way that the transformed message is
more compressible.
 Therefore used as an extra step in compression.
 Technically, it is an invertible transform of a sequence of input
characters to an array of output numbers.
 It is first of the three steps to be performed in succession while
implementing Burrows – Wheeler Data Compression algorithm
that forms the basis of the Unix compression utility bzip2.
Move-To-Front Encoding
A Move-To-Front coder is used for preprocessing the input
before it is fed to the actual compressor.
Encoding works as follows:
The coder maintains a list L containing all the 256 characters
that can appear in the input.
Whenever it receives an input character c it looks up the
position i of c in L , outputs i and moves c to the front of L .
Let us look at an example.
 Assume that the position of every character in the initial
list is equal to its ASCII-code.
When we encode the sequence aaabbbbaab
 we obtain the output 97, 0, 0, 98, 0, 0, 0, 1, 0, 1 .
Move-To-Front Encoding
 A  MTF Coder has the following properties:

 If the input contains sequences where one character is repeated many tim
then the output will have a lot of consecutive zeros.

 A sequence in the input where a small set of different characters is used


corresponds to a sequence in the output with (mainly) small integers.
Move-To-Front Encoding
 The main idea behind MTF:
 1. The primary idea behind MTF is to maintain an ordered list of lega
symbols (a to z, given in example).
 2. Read one character at a time from input string .
 3. Print out the position at which that character appears in the list.
 4. Move that character to front of the list and repeat the process until i
for all input characters are obtained.
Move-To-Front Encoding
 Use Move-To-Front Encoding Scheme to Encode L= "ccdcabb“,
assume the source alphabet is given by A={a b c d e}.
 Solution:
 We start by creating a list(L) of all possible characters that may occur in an input
stream.

0 1 2 3 4

a b c d e
Move-To-Front Encoding
 First input character: "c"
L= "ccdcabb“
The list is:
0 1 2 3 4

a b c d e

We see that c is at position 2 in the list, so we output "2".


At the same time, we move c to position 0, pushing a and b
one place to the right. 
0 1 2 3 4

c a b d e
Move-To-Front Encoding
 Next input character: "c" (the second c in "ccdcabb")
The list is:

Using the same procedure, we output "0", since c is now


at position 0.
Again we move c to the front, but since it's already
there, this doesn't change the list.
Move-To-Front Encoding
Next input character: "d" L= "ccdcabb“
The list is:

This will output "3", since d is at position 3, and now we


will move d to the front, pushing c, a, and b to the right.
0 1 2 3 4

d c a b e
Move-To-Front Encoding
Next input character: "c"
L=
"ccdcabb“
This will output “1", since c is at position 1, and now we will
move c to the front, pushing d to the right.

The list is:


0 1 2 3 4

c d a b e
Move-To-Front Encoding
Next input character: “a"
L= "ccdcabb“
This will output “2", since a is at position 2, and now
we will move a to the front, pushing c, d to the right.
0 1 2 3 4
a c d b e
 Next input character: “b“
This will output “3", since b is at position 3, and now we will
move b to the front, pushing a,c, d to the right.
0 1 2 3 4
b a c d e

Encoded Output is 2031233


Move-To-Front Encoding Analysis
 As you can see from the above example:
 if the input is like "abbbbbbc", then the sequence of b's will result in l
0's in the output which makes it more compressible..
 since b will be moved to the front of our list when the first b is encoun
Move-To-Front Algorithm Drawbacks
 The problem with the basic MTF transform is that it is performing
the same changes for any character, regardless of its frequency of
occurrence, which can affects efficiency of compression as
characters that occur rarely are pushing frequent characters to
higher values.
 Various modifications have been made for this reason.
 One common change is that characters above a certain point can only be moved
to a certain threshold.
 Another change is to make some algorithm that runs a count of each character's
local frequency and uses these values to choose the characters' order at any point.
 Many of these transforms still reserve zero for repeat characters,
since these are often the most common in data after the Burrows
Wheeler Transform(BWT).
For Any Query/Doubt You can mail at
Swati.singh@imsec.ac.in
Thank You
Data Compression (RCS087)
Move-To-Front Decoding

Prepared By:
Dr. Swati Singh
Assistant Professor, CSE Deptt
IMS Engineering College, Ghaziabad
DR. A. P. J. ABDUL KALAM TECHNICAL UNIVERSITY, Uttar
Pradesh
Move-To-Front Algorithm
 The MTF (Move to Front) is a data transformation algorithm that
restructures data in such a way that the transformed message is
more compressible.
 Therefore used as an extra step in compression.
 Technically, it is an invertible transform of a sequence of input
characters to an array of output numbers.
 It is first of the three steps to be performed in succession while
implementing Burrows – Wheeler Data Compression algorithm
that forms the basis of the Unix compression utility bzip2.
Move-To-Front Algorithm
 A  MTF has the following properties:

 A sequence in the input where a small set of different characters is used


corresponds to a sequence in the output with (mainly) small integers.

 If the input contains sequences where one character is repeated many tim
then the output will have a lot of consecutive zeros.

 So, this consecutive zeros signifies the same symbol occurrence in decod
Move-To-Front Decoding
 The output of MTF encoder is a position in the list and not an actual
or character, and then it proceeds to transform the table.
Thus, because the table is transformed only after the position is transm
the MTF decoding algorithm also maintain the same table created by
encoding method, since they both start with the same list.
The decoder accepts list positions and not symbol codes.
 In Decoding we have “translate” that list position into the correct out
symbol found at that list position.
Again, the table would have to be reconstructed to move-to-front the n
symbol received.
Hence, the same table is being used as a “look-up” table of the MTF
encoding and decoding algorithms for reconstruction of the data sourc
Move-To-Front Decoding
 Use Move-To-Front Decoding Scheme to decode “2031233“,
assume the source alphabet is given by A={a b c d e}.
 Solution:
 We start by creating a list(L) of all possible characters that may occur in an input
stream.

0 1 2 3 4

a b c d e
Move-To-Front Decoding
 First list position: “2"
decode “2031233“
The list is:
0 1 2 3 4

a b c d e

We see that c is at position 2 in the list, so we output “c".


At the same time, we move c to position 0, pushing a and b
one place to the right. 
0 1 2 3 4

c a b d e
Move-To-Front Decoding
 Next list position : “0“ decode “2031233“
 The list is:

Using the same procedure, we output “c", since c is now


at position 0.
Again we move c to the front, but since it's already
there, this doesn't change the list.
Move-To-Front Decoding
Next list position : “3" decode “2031233“
The list is:

This will output “d", since d is at position 3, and now we


will move d to the front, pushing c, a, and b to the right.
0 1 2 3 4

d c a b e
Move-To-Front Decoding
Next list position : “1"
decode
“2031233
This “ “c", since c is at position 1, and now we will
will output
move c to the front, pushing d to the right.

The list is:


0 1 2 3 4

c d a b e
Move-To-Front Decoding
Next list position : “2"
decode “2031233“
This will output “a", since a is at position 2, and now
we will move a to the front, pushing c, d to the right.
0 1 2 3 4
a c d b e
 Next list position : “3“
This will output “b", since b is at position 3, and now we will
move b to the front, pushing a,c, d to the right.
0 1 2 3 4
b a c d e

Decoded Output is ccdcabb


Move-To-Front Algorithm Drawbacks
 The problem with the basic MTF transform is that it is performing
the same changes for any character, regardless of its frequency of
occurrence, which can affects efficiency of compression as
characters that occur rarely are pushing frequent characters to
higher values.
 Various modifications have been made for this reason.
 One common change is that characters above a certain point can only be moved
to a certain threshold.
 Another change is to make some algorithm that runs a count of each character's
local frequency and uses these values to choose the characters' order at any point.
 Many of these transforms still reserve zero for repeat characters,
since these are often the most common in data after the Burrows
Wheeler Transform(BWT).
For Any Query/Doubt You can mail at
Swati.singh@imsec.ac.in
Thank You

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy