Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

A Lossless Image Compression Algorithm Using Variable Block Size Segmentation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

1396 IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 4, NO. IO.

OCTOBER 1995

A Lossless Image Compression Algorithm


Using Variable Block Size Segmentation
N. Ranganathan, Senior Member, IEEE, Steve G. Romaniuk, and Kameswara Rao Namuduri

Abstract-The redundancy in digital image representation can in combination with lossy methods have been used in some
~
be classified into two categories: local and global. In this paper, image applications. For example, the baseline system proposed
we present an analysis of two image characteristics that give rise in ISO-JPEG [18], an international still image standard, rec-
to local and global redundancy in image representation. Based
on this study, we propose a lossless image compression scheme ommends the use of Huffman coding or arithmetic coding
that exploits redundancy both at local and global levels in order to to encode the compressed image obtained after transform
obtain maximum compression efficiency. The proposed algorithm and quantization steps to further exploit redundancy. Lossless
segments the image into variable size blocks and encodes them methods are also used in specialized applications such as med-
depending on the characteristics exhibited by the pixels within ical imaging and satellite photography (such as level 0 or level
the block. The proposed algorithm is implemented in software
and its performance is better than other lossless compression 1A space image data of NASA [20]) where reliability of repro-
schemes such as the Huffman, the arithmetic, the Lempel-Ziv duction of images is a critical factor. For a survey of various
and the JPEG. methods for image compression, the reader is referred to [21].
The redundancy in digital image representation can be
I. INTRODUCTION classified into two categories: local and global. These two

D ATA compression is the process of eliminating or re-


ducing the redundancy in data representation in order
to achieve savings in storage and communication costs. Data
types of redundancy could be attributed to two specific char-
acteristics exhibited by the image data. Local redundancy
corresponds to the coherence, smoothness or correlation in
compression techniques can be classified into two categories: the image data that is due to the fact that the gray level values
lossless and lossy schemes. In lossless methods, the exact within a neighborhood vary gradually rather than abruptly.
original data can be recovered while in lossy schemes only a Illumination and shadowing effects also contribute to gradual
close approximation of the original data can be obtained. The variation of data in images. Global redundancy could be
lossless methods are also called entropy coding schemes, since attributed to the repetition of patterns within an image. Image
there is no loss of information content during the process of compression algorithms eliminate or reduce local redundancy
compression. In lossy compression methods, transform coding by representing the neighborhood in a compact form. For
techniques such as Fourier [27], Karhunen-Loeve [25], orthog- example, in run length coding 151 scheme, runs of pixels
onal transforms [26], and other techniques such as DPCM [22], with the same gray level are replaced by the gray level and
vector quantization [l I], [15], [17] are used and such methods its run length. In compression schemes based on differential
produce compression ratios of up to 100-to-1 depending on pulse code modulation [22], [23] and predictive coding [24]
the quality of images obtained after reconstruction. methods the next input is predicted based on the digitally
The classical lossless compression schemes are based on coded past. Global redundancy can be eliminated or reduced
tree-based codes that represent a large class of variable-length by encoding the repeated patterns (linear or 2-D sub-blocks)
encoding schemes such as Huffman codes [4], Shannon-Fano by using suitable coding methods. Lempel-Ziv [7], [8] scheme
codes [l], 121, universal codes of Elias [6], the Fibonacci codes searches for repeated linear patterns within a fixed size window
[ 3 ] ,etc. The tree-based compression methods have been used and replaces the repeated patterns by suitable pointers to the
for large scientific and text files as well as image date and usu- previous occurrences. Arithmetic coding [13] and Huffman [4]
ally yield compression ratios in the range from 2-3. In the ab- schemes exploit the skewness in the distribution of patterns
sence of a suitable model of data to be encoded, the arithmetic for optimal encoding of the given data. Lossy compression
[13], [16] and Lempel-Ziv codes [7], [SI and the run-length schemes based on vector quantization [l 11 parse the image into
code [5] provide better adaptive codes. The lossless methods a sequence of groups of pixels. Each group of pixels is referred
to as a vector. The encoder views an input vector and generates
Manuscript received May 11, 1993; revised October 24, 1994. This work a channel codeword. The decoder uses a look-up table indexed
was supported in part by a grant from Enterprise Florida Innovation Partner-
ship FTRI Fund (formerly Florida High Technology and Industry Council). by the channel codeword to decode the compressed data [21].
The associate editor coordinating the review of this paper and approving it Most of image compression methods follow either local or
for publication was Prof. Rama Chellapa. global redundancy elimination methods. However, for achiev-
N. Ranganathan is with the Center for Microelectronics Research, Depart-
ment of Computer Science and Engineering. University of South Florida, ing the maximum possible compression rates it is mandatory
Tampa, FL 33620 USA. to exploit redundancy both at local and global levels.
S. G . Romaniuk is with the Department of Information Systems and The contribution of the paper is two-fold. In the first part
Computer Science, National University of Singapore, Singapore 051 1.
K. R. Namuduri is with GTE Information Services, Tampa, FL 33602 USA. of the paper, a mathematical analysis of local and global
IEEE Log Number 9413840. characteristics exhibited by image data is presented with an
1057-7149/95$04.00 0 1995 IEEE
RANGANATHAN et al.: A LOSSLESS IMAGE COMPRESSION ALGORITHM USING VARIABLE BLOCK SIZE SEGMENTATION I397

objective of deriving a lossless image compression method is desirable to study the distribution of such characteristics
that works well on most of the images. In general, the perfor- in images in general and pick those characteristics that will
mance of image compression methods are image dependent. result in higher compression efficiency. Then it is possible to
A compression scheme performs well on a given image, design a versatile algorithm (i.e., an algorithm that works for
if the scheme is based on exploiting the specific type of most types of images). Further more, it is important to select
characteristic that is present within the image. Hence, in order the design parameters carefully so that the algorithm works
to derive a compression scheme that performs well on most efficiently (in terms of computational time as well as com-
images, we need to find out the characteristics that are widely pression efficiency). In this section, two image characteristics:
exhibited by images. Estimating the distribution of image smoothness and similarity that appear widely in images are
characteristics and the resulting compression efficiency is a studied in detail in order to understand their effect in image
very difficult task due to the huge amount of computations compression. The two characteristics are discussed below:
involved. However, by observing a simplified image domain I ) Smoothness: A given neighborhood (or block) in an
(images of size 32 x 32 with 256 gray levels) closely, we were image often exhibits coherence or correlation a property that
able to plot and compare the distributions of two common is commonly referred to as smoothness of the data. The
types of image characteristics generally utilized for lossless difference ( d ) between the minimum and maximum gray levels
image compression. This mathematical analysis also provides within a neighborhood is a suitable parameter to measure the
an understanding of the effect of some design parameters such smoothness. For example if d = 0, it means that every pixel
as the block size and search space on compression efficiency. in the block is of same gray level. In this case, the block
The second part of the paper presents an algorithm for can be represented by one pixel and the size of the box.
lossless compression based on some of the direct observations This representation is same as the run-length coding and it
from the mathematical model. The proposed image compres- requires the least amount of space. Even if the difference is
sion scheme exploits both types of redundancy in order to not equal to zero, it will generally be very small within a
get maximum compression for most types of images. The neighborhood. Hence, any given neighborhood can be rep-
performance of the proposed algorithm is studied by software resented by the minimum gray level (min) in the block and
implementation. The proposed algorithm works better than the offsets corresponding to the other pixels in the block with
other lossless compression schemes such as Huffman [4], respect to the min. Such a scheme is referred as base-offset
arithmetic [16], Lempe-Ziv [7], [8], and the JPEG [29]. The scheme (for representing a neighborhood) in this paper. By
knowing the value of d within a block, it is clearly possible
performance factor, Compression Efficiency (CE), used in this
to compute the compression efficiency that can be obtained
paper for performance comparison is defined as follows:
within the block. Since the parameter d directly affects the
original image size - compressed image size compression efficiency, it can be considered as the parameter
x 100. for estimating the efficiency of compression algorithms based
original image size
on the smoothness characteristic.
The outline of this paper is as follows: A detailed ex- 2 ) Similarity: In general, a given pattem might repeat itself
planation of two typical image characteristics that lead to anywhere in the rest of the image. If a pattern repeats itself n
redundancy is presented in Section 11. A mathematical model times in an image, then (n - 1) patterns can be replaced by
that represents the distribution of the image characteristics and pointers to one of the occurrences of the pattern. For example,
quantitative analysis of the model is presented for a sample Lempel-Ziv compression schemes search for linear repeated
image domain. Based on this study, a new algorithm for patterns (or strings) in the data and replaces them with pointers
lossless image compression is proposed in Section I11 and to their previous occurrences [7], [8]. To determine how good
its complexity analysis is presented in Section IV. Section
this characteristic is from image compression point of view,
V concludes the paper.
we need to partition an image into subregions, consider each
11. LOCALAND GLOBALREDUNDANCY subregion as a pattern, and estimate how many times each
IN IMAGES: AN ANALYSIS pattern repeats itself in the entire image. Once the amount of
repetition is known, the compression efficiency that can be
In general, images exhibit characteristics that give rise to
achieved on the image can be estimated. We reformulate this
local and global redundancies in image representation. The
similarity estimation problem as a grid coloring problem in
compression efficiency that can be obtained on an image
Section 11-B and estimate the distribution of this characteristic
depends mainly on the image characteristics. Hence, image
within images.
compression schemes are generally designed to exploit the
presence of such characteristics. Further, implementation as- As a first step in the mathematical analysis, the set of all
pects such as the image partitioning strategy, the block size, the images of a given representation scheme is divided into a
area of search space, etc., influence the compression efficiency distinct number of classes. This classification is based on the
as well as the computational complexity. An algorithm will degree of smoothness and similarity present in each class of
achieve the best possible compression efficiency if 1) it ex- images. The purpose of this classification is:
ploits all the characteristics that contribute to the compression to estimate the number of images that exhibit a specific
and 2) employs efficient implementation strategies. However, Characteristic (smoothness or simdurity) at varying levels.
it is not possible to design an algorithm that will exploit to estimate the maximum compression that is possible to
every characteristic that leads toward compression. Hence, it obtain in each class of images.
1398 IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 4. NO. IO, OCTOBER 1995

to compare the distributions of the characteristics in K x K . That is


order to find out which characteristic gives rise to better c-I
compression.
and to estimate the influence of certain design parameters d=O
such as the block size and the are of search space on
compression efficiency. Consider the summation (from (2)) K2-1 EEC1 (4')
For this analysis, the set ZN of images of size N x N , d l)J-,. Let a = K 2 . Expanding the two sum-
( K : ~ z ) (-
K l
with C number of colors is considered. The cardinality of this mations we obtain
set is C N 2 This
. set of images is classified into n number of
different classes (SIto S,) based on the distribution of the
a-1 a-1

i=l j=;
(;) ( a - 2 ) ( d - 1)-
u-.7
two characteristics i) smoothness and ii) similuriry in them.

A. Clussijicution Based on Smoothness Characteristic


= (y) [(a;')(d-i)a-2+( a - 1 )(d-1)-3

To study the smoothness characteristic, a given image is


divided into a set of blocks. Given that each pixel can take + . . . + (aU --1 l ) ( d - I ) O ]
any gray color value from the set [0, C - I], the maximum
difference in any block lies within [O! C - 11. Below, we +(;) [(u;2)(d-i)a-3+( a-2
present a theorem and prove that this classification is indeed
possible.
Theorem 1: Let N x N be the image size, and let C be the
+ . . . + (Ua --22 ) (d - 4
maximum number of gray color values in any given image
I E ZN. Then the set of images ZATcan be classified into (3)
a finite number of disjoint subsets based on the degree of
smoothness exhibited by the images, such that there is an upper The above summation can be simplified by observing that
bound of compression efficiency associated with each of the +
E:=l ( : ) . T ~ - ~= (x 1)" - xn. This simplification results in
subsets.
Proof: This theorem is proved in two steps. First, the
total number of distinct blocks of size K x K are classified
into a finite number of disjoint subsets based on the maximum
difference ( d ) between any two pixels in the K x K block. = (;) p-1 - ( d - 1)"-1]
In the second step, each image is considered as an assembly
of K x K blocks and the entire set of images thus formed + (2) pa-2 - ( d - 1)"-2]
is classified into a finite number of disjoint subsets based on
the upper bound of compression that can be achieved on each
subset of images.
If within a K x K block, each pixel takes on a value from
within the range [0, C - 11, and if the maximum difference
between any two pixels in the K x K block is d , then the
number of distinct K x K blocks N [ K ,d] that can be formed = [(d+ 1)" - d" - 11 - [(d)" - (d - l)a- 11
is given by the following formulas. = (d + 1)" - 2d" + (d - 1)". (4)
N [ K .01 = C Using the above result, we can express the summation of
i=K2-l subsets;
:
:
1 N [ K ,d ] given in (2) as follows:
N [ K ,11 = ( C - 1) c-1
i=l ( K2 ' )
K2-1 KL-1
K2- i d=2
K2-j c-1
a=1 j=a = (C - d)[(d + l ) a- 2d" + ( d - l)"]
. (d - for 1 < d 5 - 1. c (1) d=2
c-1
The above formulas can be interpreted as follows: When d
is equal to zero, the number of distinct patterns that can be =C [(d + 1)" - 2d" + (d - l)"]
d=2
formed in a block of size K x K will be equal to the maximum
c-1
gray colors allowed (C) and so on. Since the classification is
based on d, and d can vary from 0 to C - 1, the number of
- [d(d + 1)" - 2d"+l + d(d - I)"]
d=2
distinct sets will be equal to C.
We prove the correctness of the above formulas by showing
= C[1 - 2" - (C - 1)"+ C"]
that the sum of distinct blocks within the above described - [2 - 2" - C(C - 1)" + (C - 1)C"]
disjoint sets adds up to the total number of blocks of size = C" + 2" + C - c*2" - 2. (5)
RANGANATHAN et al.: A LOSSLESS IMAGE COMPRESSION ALGORITHM USING VARIABLE BLOCK SIZE SEGMENTATION I399

The above result delivers the summation from N [ K ,21 to distribution of different K x K blocks in an image) is known,
N [ K ,C - 11. Adding N [ K ,01, which is equal to C , and then the compression efficiency that can be obtained on a given
N [ K ,11, which is equal to (C - 1)2" - 2(C - 1) results image can be determined from the following equation.
in the sum of all subsets, yielding N [ K ,d] = C" =
~~~~

C K 2 .This proves the validity of (1).


Given a block of size K x K in which pixels can take any
value from within the set [O, C - 11, if the maximum difference
between any two pixels is d, then the number of bits required
( B R [ K ,4) to represent the block using base-offset method
described in Section I, is given by A'-lc [( N / K ) J- 1 'I
B R [ K ,d ] = log, ( C )+ ( K , - 1) log, ( d + 1). (6)
The above equation is derived as follows: A K x K block
can be represented by its first pixel that requires log, ( C )bits
+
followed by K 2 - 1 offsets each with log, ( d 1) bits. Hence,
the compression efficiency C E [ K ,d] for K x K block is given
by To obtain a compression efficiency of X % , within a deviation
E , every image requires all tuples obey the following condition:

Given N the size of an image, C the number of possible


colors assigned to each pixel, K the block size, and C E [ K ,d] Let us define the set S of tuples as
the compression efficiency for different values of d, then the
( C ) ) subject to
S = {(ao, a l l . . . , qOg,
entire set of images ZJ,Tcan be classified into a finite number
of disjoint subsets based on an upper bound of compression Condition (10) and Condition (11) }. (12)
that can be obtained for such images as shown below.
An image of size N x N can be viewed as an assembly of S is the solution space of all tuples that satisfy conditions (1 1)
K x K blocks where the total number of K x K blocks is and (12). Furthermore, let us define BCi as representing the
given by L( N / K ) 2 i .Each of these K x K blocks gives rise to total number of K x K blocks in which the degree of variance
a different compression efficiency depending on the maximum d varies from 2; to 22+' - 1 according to (9).
difference d within each K x K block.
The gray level values 0 through C - 1 can be partitioned BCi = N [ K ,01, when i =0
yf1-1
into log, (C) sets depending on the number of bits required
to represent the gray level. These subsets are as follows:
partition: range of gray levels
For any tuple A E S, we can calculate the total number of
partitiono: (0, 1 ) combinations (Comb [ A ]in) which all K x K blocks belonging
to tuple A can be arranged to form an image, such that every
partitionl: ( 2 , 3) one of the constructed images can be compressed by X %
partition2: (4, 5, 6, 7) within a deviation E . We can write
partition 3: (8, . . . , 15)
...
partitionl: (2, . . . 21f1 - I). (8) i=O

Let A: (ao, a l , . . . , a l ) represent a tuple where the compo- Comb [A]represents the number of images that can be formed
nents a; represent the number of K x K blocks belonging to from the K x K blocks selected according to the tuple A.
the partition i , subject to the following conditions: Finally, we can estimate the total number of images that can
be formed from all tuples belonging to the set S as
i E [O, log, (C)l
Comb[S]= Comb[A]
AES

Since the tuples in S are chosen according to (1 1), Comb [SI


(9) represents the number of images that give rise to X f e%
compression. Thus, we have shown that the set of all images
Each tuple A gives a possible distribution of different K x K 1, can indeed be partitioned, such that on every image I E 1,
blocks in an image of size N x N . Suppose A (i.e., the X % compression within a deviation f c can be obtained. U
1400 lEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 4. NO. 10. OCTOBER 1995

B. Classification Based on Similarity Characteristic nonoverlapping blocks. If K x K is the size of each block,
In this section, a classification of images based on the the image can be subdivided into b uniformly sized blocks,
similarity characteristic is described. Suppose, an image is where b is equal to ( N 2 / K 2 ) Each
. of the blocks can be
divided into blocks of size K x K , then it consists of h blocks, assigned p color patterns, where p = C K 2 .If there are IC
where each block can take on p possible patterns, where b and distinct patterns in the image, then an upper bound for the
p are given by compression efficiency is given by ( b - k / h ) x IO0 since
( b - k ) out of b blocks can be replaced by pointers. Since,
the image consists of b blocks and there are p patterns to
choose from, the number of distinct patterns in the image can
p =CKL. (16) vary from I to b (if b < p ) or from 1 to p (if p < 6). This
Furthermore, let P be the set of all possible color patterns implies, that the entire set of images can be subdivided into
associated with any given block, then we say the cardinality b or p disjoint subsets (Cl, cz, ..., ch, ..., cp) based on
N [ P ] = p. For the sake of argument, let the compression the number of distinctly colored blocks in the image. Each of
efficiency we are aiming at be 60%. This desired goal of these subsets gives rise to a different compression efficiency.
compression is possible only if 40% of the blocks are colored Using the block coloring example discussed earlier, we can
such that every block is distinct from every other pattern and determine the number of images in each of these subsets (Cl,
the remaining 60% of the blocks are colored with duplicated C2, ..., Cb, ..., Cp). Let N[Ck]be the cardinality of the
patterns. The cardinality of the set of images exhibiting such subset C k .
characteristic can be determined by estimating the number
of ways b blocks can be colored, such that exactly 40% of
them are colored with distinct patterns selected from p color
patterns. Suppose one is given a grid consisting of 36 blocks
to paint and a color palette with 12 different colors. How
many ways can one paint this grid using exactly 1, 2, 3 ,
. . ., 12 colors? This task can be performed as follows: let
N[Ck]represent number of ways the grid can be colored using
exactly k colors. To estimate N[C1],we find out the number
of ways one color can be selected from 12 colors. which is
equal to (‘f)and multiply this number with the number of
ways the grid can be colored using one color. This gives us ..
the result N[G1] = (‘1”).
To determine N[C2],first we find
out the number of ways two colors can be selected from 12
colors, which is equal to ( i2)
and multiply this number with
the number of ways the grid can be colored using exactly
two colors. The number of ways the grid can be colored
with exactly two colors can be determined by subtracting the
number of ways the grid can be colored using any one of
the two colors, which is equal to (:)1 from the number ways
the grid can be colored using up to two colors This
gives us the result N[C2]= - (;)I. Following this
procedure, we can determine N[C3],N[C;1], ..., N[12]. All
,
the images in the class N [ C k ]can be compressed to ( k / 3 6 ) %
giving rise to (36 - k/36)0/;, compression efficiency where
I; varies from 1-12. Notice that the maximum value of I; is
equal to the smaller of the two values b and p . Hence, the
possible compression efficiencies run from O / h to ( h - I / b ) %
in steps of l / b increments or from O / b to ( p - l / b ) % in steps
of l / b increments depending on whether b is smaller or p is
smaller. The following theorem provides the classification of
images based on the characteristic similarity with respect to
the compression efficiency parameter. f
Theorem 2: Let iV x N be the image size, and let G be the
maximum number of gray values in any given image 1 E ZAT.
Then the set of images Z , can be classified into a finite
number of disjoint subsets based on the similarity exhibited
by the images, such that there is a maximum upper bound of
compression efficiency associated with each of the subsets.
Pro08 To utilize the characteristic similarity, a
given image is required to be decomposed into a set of
RANGANATHAN et al.: A LOSSLESS IMAGE COMPRESSION ALGORITHM USING VARIABLE BLOCK S U E SEGMENTATION 1401

A straightforward way to verify the above classification is by


checking whether the sum of all subsets adds up to the total
number of images C N 2 Consider
. the expression for N[C,]
given in (17)

+ + + N[C,] = pb.
N[C1] N[C2] . . .

This implies that the sum of all subsets adds up to p h , which


is equal to the total number of images CA''.Generally, p is
larger than b. If there are 6 blocks in the image, the image can
have 1 to h distinct patterns in which case N[Cb+l],N[Cb+*],
..., N[C,] evaluate to zero. This implies that there will be
exactly h number of distinct classes. 0

C. Analysis
In this section, we provide an analysis based on the math-
ematical model presented in the previous subsections. The
model requires three parameters (C. K , N ) to represent a
set of images. First, the distributions of each of the two
characteristics smoothness and similarity are independently
estimated for the set of images represented by (C = 256,
K = 2, and N = 8).
These results are shown in Fig. l(a). The plots shown
in Fig. l(b) and (cj are obtained by keeping the maximum
number of gray colors (C = 256) and the block size ( K = 2 ) Compression Efficiency
constant and increasing the size of the image ( N ) . The com- (b)
putations are performed using Mathematica software package. le+03 . . . , . . . .
Due to the huge size of numbers involved, it was possible
to compute the distributions of the characteristics for images
of size up to 32 x 32 only. The plots clearly indicate that as
the size of the image is increased, the global characteristic
similarity becomes a versatile characteristic and it contributes
significantly to the compression efficiency. From this first
set of results we conclude that any compression scheme
should exploit a global characteristic in order to achieve good
compression efficiency. In order to increase the compression
rates, it is desirable to look for more than one characteristic.
In particular, a combination of disjoint characteristics (with
no common aspects) such as similarity and smoothness will CompressionEtllciency
result in more efficient compression algorithms. One important (c)
issue in implementing a compression scheme based on a global Fig. 1. (a) Distribution of characteristics in images of size S x 8 with 256
characteristics such as similarity is the degree of global search gray colors. (b) Distribution of characteristics in image size 16 x 16 with
that should be conducted. In Fig. 2(a), we show the effect of 256 gray colors. (c) Distribution of characteristics in images of size 32 x 32
with 256 gray colors.
block size ( K ) on the number of images of size N (=16
in this case) exhibiting similarity characteristic. Obviously,
as the size of the block is increased the number of images
that have a high degree of similarify decreases drastically. scheme such as similarity practically feasible for large N . The
The observed behavior can be explained by the simple fact loss in possible compression on the other hand due to this
that as the block size ( K ) increases the probability of finding restriction will be limited. Finally, the last graph Fig. 2(b)
identical matches in a fixed size image decreases (fewer depicts the results for different sizes of K for exploiting the
combinations can be detected). From this, we can conclude smoothness characteristic. Similar to the previous graph this
that the choice of K should be limited to a few small graph shows that for most of the images significant portion of
values rather than attempting matches for large K . This also compression efficiency can be obtained by selecting a block
implies that the probability of finding pattern matches outside size of 2. Selecting larger sized blocks can improve results.
some small predefined neighborhood decreases. This has the When N = 16 for example, a block size of 4 gives highest
desired benefit of decreasing search time and making a global compression efficiency for most of the images. From this
1402 1EEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 4, NO. 10. OCTOBER 1995

TABLE I
-K=2 LOCALAND GLOBAL
CODING
SCHEMES
USEDIN THE COMPRESSION
ALGORITHM
.... K . 4

K=B Category I Block I Of€set I Coding I length

Compression Eficiency
(a)

Compression Efficiency
(b)
east). Hence, it is not necessary to represent the base
Fig. 2. Distribution of characteristics in images of size 16 x 16 and block
sizes of K = 2. 4. and 8. (a) Distribution of similarity characteristic. (b) pixel. Instead, the direction of the selected reference
Distribution of smoothness characteristic. pixel is specified by using two bits. The direction of the
reference pixel is updated for every block. The selection
of the reference pixel from the neighboring pixels is
observation, we can conclude that for exploiting smoothness, based on the nearest neighborhood principle presented
variable block segmentation is necessary. For the purpose of in [28]. The header entry for this block consists of the
this paper, any further experiments are not required, but may category to which this block belongs (in which the size
be considered for future work. Instead, we next draw our of the block is implicitly encoded) and it is stored in
attention to applying the results found so far in developing a separate header file. Since three different sizes are
a compression algorithm. considered, three categories (0, 1, and 2 as shown in
Table I) belong to this classification.
111. A LOSSLESS IMAGE COMPRESSION ALGORITHM 2) Block matching: In our scheme, the area of search
USING VARIABLEBLOCKSIZESEGMENTATION space is chosen as four times the size of the block
In our implementation, a given image is segmented into being considered. The codeword for this coding scheme
square sized blocks of sizes eight, four, and two. Each block consists of the differences along z and y directions from
is classified into one of the twenty eight categories depending the pattern under consideration and an identical pattern
on the size of the block as well as characteristic exhibited by if it was found within the search space. Hence, the
the pixels within the block. Three coding schemes are utilized length of the codeword depends on the area of search
to encode these blocks. The coding schemes and the codewords space. For a 2 x 2 block, the length of the codeword
for each of the twenty eight categories are listed in Table I. is eight. Category 5 (shown in Table I) falls under this
1) Run-length coding: If the maximum difference (d) within classification. Again, the header for the block consists
a block is zero, (i.e., all the pixels in the block under of the category to which the block belongs and is
consideration are of the same color), run-length coding stored separately in a header file. In our algorithm, block
is utilized to optimally encode the block. In this case, the matching is implemented only for 2 x 2 blocks to reduce
block can be represented by one pixel (the base) and the the computational complexity involved with the search.
size of the block. In our scheme, each pixel is encoded 3 ) Base-offset coding scheme: Base-offset coding scheme is
as an offset with respect to one of its three neighboring followed if the maximum difference d within the block
pixels (north, east, and north east) or with respect to is sufficiently small but not equal to zero. For 8 x 8 and
the average of two of its neighboring pixels (north and 4 x 4 blocks, the codeword consists of offsets for all
RANGANATHAN et al.: A LOSSLESS IMAGE COMPRESSION ALGORITHM USING VARIABLE BLOCK SIZE SEGMENTATION 1403

pixels in the block and the direction of the base pixel. Segment the image into
The categories 3, 4, and from 6 2 6 (in Table I) belong blocks of size K x K.
For each block repeat
to this classification. The length of the codeword (which
the following steps.
excludes the header information) is equal to n x log,
(Maximum offset) where n is the number of pixels in
the block and two bits to represent the direction of the difference
base pixel. Else encode the blwk
If none of the above schemes are applicable, then the pixels using base-offset scheme
in the block are represented as they are without any encoding
(category 27 in Table I). This scheme is followed only for
2 x 2 blocks. Four bytes are required to represent the block.
The category information is stored separately in the header file.
K=2?

A. Proposed Algorithm
The proposed algorithm for lossless image compression is
no
given in the form of a flow chart in Fig. 3. The algorithm
works as follows: Initially, the given image is partitioned
into uniformly sized blocks of size K x K . In our scheme,
the initial value of K is selected as eight. If all the pixels
Subdivide the block into
four smaller blocks of
size W2 x W2. For each
subblock repeat the
above steps.
Encode the block
using base-offset
I
in the block are of the same gray level, then the block is
encoded using run length encoding scheme. If the degree of
variation in the block is reasonably small, then the block Fig. 3. Flowchart for the proposed compression algorithm.
is coded using base-offset method. If both the above tests
fail, then the block is subdivided into four smaller blocks of
size K / 2 x K/2. Each of the four blocks are again analyzed Iv. AND SPACE COMF'LEXITY ANALYSIS
for the local and global characteristics described above. This
In this section, the time and space complexities (we refer
procedure is continued successively by reducing the size of
the blocks to half of their size at every step till the block size to run-time storage requirement) of the proposed algorithm
( K ) becomes 2 x 2. When the size of the block is 2 x 2, a exploiting the smoothness and similarity characteristics are
analyzed. The results of the analysis are stated in the following
different approach is followed. If all pixels in the block are
theorem.
of same gray level, the run length coding scheme is applied.
Otherwise, the neighborhood area of the block is searched to Theorem 3: Let N x N be the size of an image and K x K
find if an identical block exists. If such an identical block is be the size of the block. An algorithm that implements the
smoothness characteristic for image compression has a time
located, then the block is encoded by a pointer representing its
distance along z and y directions from its previous occurrence. order OTime(N>K ) = N 2 and requires Ospac-(N, K ) = K 2
space. The time and space complexities are the same for
If both above tests fail, then the block is coded using the base-
offset scheme provided the degree of variation is less than a average, best and worst cases. An algorithm that is based on
specified threshold. similarity has the following complexity behavior:
If the degree of variation exceeds the threshold, then the four
pixels in the 2 x 2 block are stored as they are without any
compression. As the image is encoded, a compressed image
file consisting of the codewords for the variable size blocks as
well as a header file are created. The header file keeps track
of the category number for each codeword and updates the
frequency of each codeword while the coding is in progress.
At the end of coding, the header file is compressed separately
using Huffman coding scheme.
For comparison purposes, we considered the LZW scheme
(compress utility on UNIX), the LZ77 scheme (gzip utility on
UNIX), the adaptive Huffman scheme (compact on UNIX), the The average, best, and 'worst case storage requirements are
arithmetic scheme [ 161 and the JPEG. The software for lossless given by
JPEG is obtained from the public domain facility at Stanford
University. The results for a selected set of fourteen images
are shown in Table 11. From this table, it can be observed that N* + K~
the proposed algorithm yields better compression compared to OAvgStorage(N1 K)= 2
all other schemes. The characteristic distribution in all the test
images is also listed in Table 111.
1404 IEEE TRANSACTIONS ON IMAGE PROCESSING. VOL. 4, NO. IO, OCTOBER 1995

E= The Holfman (Unix compact) scheme, A= The arithmetic scheme, LZ = The Lempel-Ziv (Unix Compress) scheme,
The LZ'I'f(Unix GZIP) scheme, Jx = The JPEG scheme with prediction method x, P = The propcaed scheme.

Proof: We first prove the results for the characteristic Hence, the time complexity for average, worst, and best case
smoothness. are as follows:
1) Average Time Case:
(hi/K )

(K2+ l ) i
( N / K ) -~
1
i=l OAvgTime(N: K, =
2
= ( K 2- 1) ($) 2 a=O

- K2 - 1
- N2
K'
= N2 (assuming K << N ) . (21)

The amount of space required by the local method is clearly


given by Uspace(N:K ) = K', since at all times a single
-
- e{ (g)4 (5)').
4 - (24)
block is tested for compression.
For the similarity characteristic, we can derive the following 2) Worst Time Case:
relationship:
( N / K ) 2-1

i=O

=K2{ (g)4-(g)'}
in which BT,, represents the number of block matching steps
required during compression. For each of the three complexity
cases, BT, is given by
3 ) Best Time Case:

i=O

Finally, the results for the space complexity for the similar-
ity characteristic are straight forward. In the worst case, the
whole image needs to be stored in form of (N/K)' K-blocks,
RANGANATHAN et al.: A LOSSLESS IMAGE COMPRESSION ALGORITHM USING VARIABLE BLOCK SIZE SEGMENTATION 1405

[9] W. Chen and C. Smith, “Adaptive coding of monochrome and color


images,” IEEE Trans. Commun., vol. COM-25, pp. 1285-1291, 1977.
[IO] R. Gallager, “Variation on a theme by Huffman,” IEEE Trans. Inform.
gory-
Categ-
0 1 2 3 4 5 6 to 26 27
Theory, vol. IT-24, pp. 668-674, 1978.
[ l 11 A. Gersho, “On the structure of vector quantizers,” IEEE Trans. Inform.
Theory, vol. IT-28, pp. 157-166, 1982.
[I21 J. Vaisey and A. Gersho, “Image variable block size segmentation,”
IEEE Trans. Signal Processing, vol. 40, pp. 204&2060, 1992.
[I31 G. Langdon, “An introduction to arithmetic coding,” IBMJ. Res. Dev.,
vol. 28, no. 2, pp. 135-139, 1984.
[14] R. Clarke, Transform Coding ofImages. New York Academic, 1985.
[15] B. Ramamurthy and A. Gersho, “Classified vector quantization of
images,” IEEE Trans. Commun., vol. COM-34, pp. 1105-1 115. 1986.
[16] I. H. Witten, R. M. Neal, and J. G. Cleary, “Arithmetic coding for data
compression,” CACM, vol. 30, no. 6, pp. 520-540, 1987.
[ 171 N. Nasrabadi and R. King, “Image coding using vector quantization a
review,’’ IEEE Trans. Commun., vol. 36, pp. 957-971, 1988.
[18] G. K. Wallace, “The JPEG still picture compression standard,” CACM,
vol. 34, no. 4, pp. 30-44, 1991.
[19] J . L. Green, “Space data management at the NSSDC applications for
data compression,” in Proc. Sei. Data Compression Workshop, Snowbird,
UT, 1988.
[20] R. B. Miller et al., “Science data management subpanel report,” in Proc.
whereas in the best case only 2 K-blocks need to be held in Sri. Data Compression Workshop, Snowbird, UT, 1988.
[21] J. A. Storer, Image and Text Compression. Boston, MA: Kluwer, 1992.
memory. On the average [22] A. Habibi, “Comparison of the nth-order DPCM encoder with lin-
(,V/K)Z ear transformations and block quantization techniques,” IEEE Trans.

ci Commun., vol. COM-19, pp. 948-956, 1971.


[23] S . K. Goyal and O’Neal, Jr., “Entropy coded differential pulse code
modulation for telsvision,” IEEE Trans. Commun., vol. COM-23, pp.
660-666, 1975.
[24] H. Kobayashi and L. R. Bahl, “Image data compression by predictive
coding I prediction algorithms, and I1 encoding algorithms,” IEM J. Res.
Dev., vol. 18, no. 2, pp. 164-179. 1974.
- N2
-
+K2 [25] A. K. Anil, “A fast Karhunen-Loeve transform for a class of stochastic
2 processes,” IEEE Trans. Commun., vol. COM-24, pp. 1023-1029, 1976.
[26] N. Ahmed and K. R. Rao, Orthogonal Transforms for Digital Signal
0 Processing. New York: Springer-Verlag. 1975.
[27] H. C. Andrews and W. K. Pratt, “Transform image coding,” in Proc.
Computer Prccessing Communications. New York: Polytechnic Press,
V. CONCLUSIONS 1969, pp. 63-84.
[28] P. G. Howard and J. S. Vitter, “Fast and efficient lossless image
In this paper, two of the most common image characteristics compression,” in Proc. Data Compression, 1993, pp. 351-360.
have been analyzed with a goal to develop an algorithm that [29] W. B. Pennebaker and J. L. Mitchell, JPEG Still Image Data Compres-
works well on most images. Based on this analysis, a lossless sion Standard. New York: Van Nostrand Reinhold. 1993.
compression algorithm is presented that utilizes both local and
global properties of images. The performance of the proposed
scheme is compared with the Huffman, the arithmetic, the
Lempel-Ziv and the JPEG lossless schemes.
N. Ranganathan (S’81-M’83-SM’92) was born
ACKNOWLEDGMENT in Tiruvaiyaru, India, in 1961. He received the
B.E. (Honors) degree in electncal and electronics
The authors thank the PVRG group at Stanford University engineenng from the Regional Engineenng College,
for making the JPEG software available in the public domain. Tiruchuapalli, University of Madras, India, in 1983
and the Ph.D. degree in computer science from the
University of Central Flonda, Orlando, in 1988.
REFERENCES He is currently an Associate Professor in the
R. M. Fano, Transmission of Information. Cambridge, MA: MIT Press, Department of Computer Science and Engineenng
and the Center for Microelectronics Research at the
1949.
C. E. Shannon and W. Weaver, The Mathematical Theory of Communi- University of South Florida, Tampa. His teaching
cation. Urbana, IL: Univ. Illinois Press, 1949.
and research interests include VLSI design and hardware algonthms, computer
A. S. Fraenkwl and S. T. Klein, “Robust universal complete codes as architecture, and parallel processing. He is currently involved in the design
alternatives to Huffman codes,” Dept. of Applied Mathematics, The and implementation of VLSI architectures for computer vision, image process-
Weizmann Institute of Science, Rehovot, Israel, Tech. Rep. CS85-16, ing, pattern recognition, databases, data compression, and signal processing
1985. applications
D. Huffman, “A method for the construction of minimum redundancy Dr. Ranganathan is a member of IEEE Computer Society, the IEEE
codes,” Proc. IRE, vol. 40, pp. 1098-1101, 1952. Computer Society Technical Committee on VLSI, the ACM, and the VLSI
S. Golomb, “Run-length encodings.” IEEE Trans. Inform. Theory, vol. Society of India He served as the Program Co-chair for VLSI Design ’94
IT-12, pp. 399401, 1966. and the General Co-chair for VLSI Design ’95. He is also on the Program
P. E h , “Universal codeword sets and representations of the integers.” Committees of ICCD, ICPP, IPPS, SPDP, and ICHPC dunng 1995. Currently,
IEEE Trans. Inform. Theory, vol. IT-21, pp. 194-203. 1975. he wrves as an Associate Editor for IEEE TRANSACTIONS ON VERYLARGE
J. Ziv and A. Lempel, “A universal algorithm for sequential data SCALEINTEGRATION (VLSI) SYSTEMS, Pattem Recognition and VLSI Design.
compression,” IEEE Trans. Inform. Theory, vol. IT-23, pp. 337-343, He was guest editor of a special issue of International Joumal of Pattem
1977. Recognition and Artificial Intelligence (IJPRAI), published in June 1995 He
-, “Compression of individual sequences via variable rate coding” is the editor of a two-volume senes on VLSI Algonthms and Architectures
IEEE Trans. Inform. Theory, vol. IT-24, pp. 530-536, 1978. published by IEEE CS Press in June 1993.
1406 IEEE TRANSACTIONS ON IMAGE PROCESSING. VOL. 4. NO. 10, OCTOBER 1995

Steve G. RomaNuk received B.S., M.S., and Ph.D. Kameswara Rao Namuduri received the B.Tech.
degrees from the University of South Florida in degree from Osmania University, India, the M.Tech.
1988, 1989, and 1991, respectively. degree from University of Hyderabad, India, and the
He was a Teaching Fellow at the National Uni- Ph.D. degree from the University of South Florida
versity of Singapore from 1992-1994. in 1984, 1986, and 1992, respectively.
He worked as a Research and Development En-
gineer in Center for Development of Telematics,
Bangalore, India from 19861988. Currently, he is
working as a System Analyst developing cellular
fraud detection products at GTE, Tampa. His re-
search interests include cellular telecommunications
and mathematical models from computer vision.

You might also like