Image Compression using Adaptive Chebyshev Polynomials

advertisement
Image Compression using Adaptive Chebyshev Polynomials
NADER AHMED AL-MUTAWWA & MOHAMED JAMAL ZEMERLY
Computer Engineering Department
Etisalat College of Engineering
P.O. Box: 980, Sharjah
UNITED ARAB EMIRATES
Abstract: - A new lossy image compression method based on adaptive Chebyshev polynomials is proposed. The
compression is achieved by representing the grey level variations across any determined section of a row or
column of an image by the coefficients of a polynomials. The performance of the method was evaluated on a
number of test images. The compression method, when compared with JPEG image compression technique, did
not achieve high compression ratio as JPEG but suggestions are given to improve its performance. However,
this technique has at least a number of advantages over JPEG when it comes to compressed image quality. It
has a direct control of the individual errors, preserves complex textured areas, fast to decompress, and last but
not least it lends itself to parallel processing as it is row or column based.
Key-Words: - Lossy Compression, Chebyshev Polynomial, Adaptive Least Squares Fitting, JPEG.
1 Introduction
In the Internet world, there is the data storage
problem caused by the increase in the use of images
in computer applications. Also nowadays the large
number of users resulted in significant amount of
data being transferred between computers.
There are many image compression techniques,
for example JPEG, that were implemented to
reduce the size of the images and so reducing the
amount of data stored. Images do not need to be
reproduced exactly. An approximation of the
original image is enough for most purposes, as long
as the error between the original and the
compressed image is tolerable.
The proposed technique is a new lossy image
compression technique that is based on representing
the grey scale variations of an image by a series of
Chebyshev polynomials. Image compression is
achieved by storing the polynomial coefficients,
which are generally fewer than the original number
of pixels.
Previous work using polynomials concentrated on
applying surface or region based fitting using
implicit polynomials [1-5]. Implicit polynomials
suffer from being ill formed and cannot reach
higher degree polynomials. Also they are
computationally expensive as the power increases.
Results of these techniques clearly showed visible
distortion that cannot be tolerated in many
applications.
The methods discussed here are concerned with
compressing images with no or very little visible
distortion. The amount of distortion introduced is
measured by a number of statistics that are usually
used to measure the quality of the reconstructed
images.
There is a compromise of how much distortion
can be tolerated from compression techniques and
usually this amount depends on the application
itself. In medical imaging, for example, the amount
of distortion is normally very small as it may affect
the validity of the diagnosis. So, visual distortion is
really an important factor when it comes to some
applications. In this paper we assume that a
maximum individual error between corresponding
pixels in the original and the reconstructed images
of 10 is visually acceptable and beyond that the
distortion may be clearly visible.
The performance of the techniques was tested on
a number of images and compared with the JPEG
compression technique [6]. JPEG has no direct
control on the individual errors in the reconstructed
image. The error is controlled indirectly using the
quality measure for which a value of 75 is widely
acceptable as generating good quality but when it
comes to individual errors this measures produces
unknown maximum individual error (for the one
case used here this error was 34).
The comparison was done using the most
commonly used image of “Lena”, as it is
considered one of the most difficult images to
compress due its texture structure. The original
image was taken as a PGM image format of ASCII
type of encoding.
2 Problem Formulation
Chebyshev polynomials are special types of
ultraspheric polynomials that are useful in such
contexts as numerical analysis and circuit design
[7-8]. They form an orthogonal set. A (type I)
Chebyshev polynomials Tn (x) are generated via
the equation:
Tn ( x)  cos( n arccos x)
(1)
Equation 1 can be combined with trigonometric
identities to produce explicit expressions for Tn (x) .
So, for Chebyshev polynomials of the first order:
T0(x) =1,
T1(x) = x,
T2(x) = 2x2 -1
Tn+1(x) = 2x Tn(x) – Tn-1(x)
x
for n >1
(2)
To calculate the coefficients of the Chebyshev
polynomial, the following method is used:
The residual sum of squares is given by:
m
 i2   {Yi ( x r )  y r }2
(3)
r 0
where y r (r =0, 1, 2 …m) is the observed or
computed values of dependent variable y at given
values xr of the independent variable x. Yi (x) is
the polynomial of degree i which minimises the
residual sum of squares
The polynomial Yi (x) may be obtained by
truncating the series after (i+1):
co po ( x)  c1 p1 ( x)  c2 p2 ( x)  ...
(4)
where pi (x) is a polynomial of degree i satisfying
the orthogonality condition:
 p (x ) p
i
r
j
( xr )  0
is the property over the interval [-1, 1], each
polynomial has a domain of [-1, 1]; thus, the series
is nicely bounded. And because of this bounded
property, approximations calculated from a
Chebyshev series are less susceptible to machine
rounding errors than the equivalent power series.
Variable x is obtained from the following
equation where [a] and [b] are the minimum and
maximum coordinates of x respectively. The usage
of this variable will affect the range of
approximation to be between –1 to 1 instead of two
arbitrary limits a and b. [7-9]
(i  j )
(5)
r
The coefficients c j in (4) are therefore given by
2 X  (b  a)
(b  a)
(7)
Choosing Chebyshev polynomials as a compression
technique is due to a number of factors:
 They are orthogonal and numerically stable.
 They offer rapid convergence for possible
truncation.
 They are normalised polynomials.
 They have the smallest maximal deviation from
zero. Under this aspect they are unique:
max
0 x 1
Tn ( x)
2
n

1
2n
[8].
Clenshaw recurrence formula is used to evaluate
(reconstruct) Chebyshev polynomials using the
following [8]:
dm+1  dm  0
dj = 2x dj+1 – dj+2 + cj
for j=m-1, m-2,.. , 1
f ( x)  d 0  xd1  d 2  c0
(8)
There are 5 statistics that are calculated to evaluate
the quality of the reconstructed compressed image.
These statistics are the Deviation per Pixel (DPP),
the Normalised Cross Correlation (NCC), the Mean
2
Square Error ( E ms
), the Signal-to-Noise ratio
(SNR) and the Compression Ratio (CR).
The Deviation per Pixel (DPP) is given by:
[8]:
y Y 1 x  X 1
 y p (x )

{ p ( x )}
r
cj
j
r
r
2
j
(6)
DPP 
  f ( x, y)  f
y 0
x 0
X Y
r
( x, y)
(9)
r
r
Approximating a curve with Chebyshev
polynomials has some important advantages. For
one, if the curve is well approximated by a
converging power series, one can obtain an equally
accurate estimate using fewer terms of the
corresponding Chebyshev series. More importantly
f ( x, y ) and f r ( x, y) are the grey levels of the
corresponding x (column) and y (row) in the
original and reconstructed images respectively. In
the above equation, X is the number of columns
(width of image) and Y is the number of rows
(height of image).
The Normalised Cross Correlation (NCC) is
given by:
y Y 1 x  X 1
  [ f ( x, y)  f r ( x, y)]
y 0
NCC 
x 0
1
2
(10)
y Y 1 x  X 1
 y Y 1 x  X 1 2

f ( x, y )]  [
f r2 ( x, y )]
[
 y 0 x 0

y 0
x 0
 
 
A value of NCC close to 1 means that the
reconstructed image is close to the original, thus a
value of 1 indicates that the image is compared to
exact copy of itself [10].
2
The Mean Square Error E ms
is given by:
y Y 1 x  X 1
2
E ms

 [ f ( x, y)  f
y 0
x 0
r
( x, y)] 2
X Y
(11)
The Signal-to-Noise Ratio (SNR) is given by:
 (255 ) 2
SNR  10  log 
 E2
 ms

 [dB]


(12)
The higher the SNR, the lower the noise is in the
reconstructed image [10].
The CR is given by:
CR 
B
C
(13)
B is the number of bytes in the original image and
C is the number of bytes needed to store the
compressed image [10].
3 Adaptive Chebyshev Fitting
There are three methods of compression that utilise
Chebyshev polynomials. Here, the first method
only was implemented and tested. These methods
are called: Method 1, Method 2 and Method 3. The
three methods all share the concept of representing
a group of pixels of the image as a Chebyshev
polynomial; however, they are different in the
fashion in which the compression of the image is
achieved. First, the implemented method, Method
1, will be described and some of the testing results
obtained will be highlighted. The way in which
Methods 2 and 3 operate will be outlined.
3.1 Method 1
There are three options for Method 1. All share the
idea of representing a group of pixels (termed
segment) by the coefficients of a Chebyshev
polynomial. These options will be described in the
next sections.
As an optional input that the user can specify,
there is the maximum allowed individual error
between the original and the reconstructed pixel
values. The default value is taken to be 5, as this
amount of difference can hardly be noticed by the
human eye [10]. The second optional input is the
number of pixels in a segment. The default value is
set to 16. In option 3 (see later), the number of
pixels in a segment is always fixed to 16 pixels.
3.1.1 Option 1: row-segment based Chebyshev
compression:
A row is divided equally into a number of segments
each with an equal number of pixels. Starting with
a degree of 0, the pixels in the segment are fitted
and all reconstructed pixels are checked against the
maximum error allowed. If the maximum error is
exceeded, then the degree is incremented and the
fitting is repeated. The same fitting procedure is
repeated until either the errors are acceptable or the
degree exceeds the maximum degree allowed,
which is the maximum of number of pixels in a
segment divided by two or 8. In the latter case, a
special value of -1 is stored (as the degree of the
polynomial) and then each pixel will be represented
by a value equals to the original data of the pixels
minus 128 (in order to fit within a byte)
A fitted segment is represented by storing the
degree of the fitting polynomial followed by the
coefficients of the polynomial rounded to bytes.
Noted that the number of coefficients = degree +1.
3.1.2 Option
2:
column-segment
based
Chebyshev compression:
This option is identical to Method 1. The only
difference is that each column in an image is
divided into a number of segments represented by
Chebyshev polynomials. Otherwise, the processing
steps of the two options are identical.
3.1.3 Option 3: 4x4 window based Chebyshev
compression:
In this option, a segment is taken as a 4x4 window.
Thus each segment consists of 16 pixels (so the
number of pixels in a segment entered by the user is
ignored). The processing steps to compress each
segment are the same as the previous two methods
but here a local neighbourhood of 4x4 is used
instead of a line or row segment. This option may
be used for checkered or textured images.
3.1.4 Comparison with JPEG
An image of “Lena” was used to compare Method
1 and the JPEG compression technique. Fig.1
shows the original image used for comparison.
Fig.2 shows the JPEG compressed image.
Fig.3 Reconstructed Chebyshev compressed image
Table 1 shows the statistics previously described
obtained from the comparison.
Statistics
DPP
JPEG
compression
2.97246
Method 1
first option
2.11659
NCC
0.999268
0.999594
2
E ms
18.2489
10.1282
SNR
35.51
38.07
Min error
0
0
Max error
34
10
CR
6.0819
2.2531
Fig.1 Lena original image
As can be seen it is very hard to detect the
differences between the original and the
reconstructed compressed image. The second
option of Method 1 was selected for comparison
with inputs of 16 pixels in a segment and 10
maximum allowed individual errors.
Table1 Evaluation statistics
3.2 Method 2
Fig.2 JPEG compressed image
Fig.3 shows the reconstructed compressed image.
Here, some of the differences are noticeable in the
hand part and some of the face parts. The image
however is considered acceptable.
In method 2, the degree of the polynomial is fixed
(default is 2 but can be changed). The number of
points in a segment is initialised to 4 (default), or
before fitting starts new points are added as long as
their grey levels are within ±10 of the average grey
level of the segment). New pixels are added as long
as the fitting gives an acceptable error (less than the
maximum specified error). The fitting stops when
the error is exceeded; in this case the previous
segment that was fitted is taken. A new segment
starts from the next pixel with the same fashion (in
a row or a column). A segment is represented by
the number of points followed by the coefficients.
The results of method 2 are expected to be better
than Method 1. A simple example to prove this is to
consider a row of an image in which all the pixels
have the same grey values. The best result of
compression obtained with Method 1, will be that
the number of pixels in one segment is set to the
maximum allowed value, which is 64, so there will
be a number of segments to compress. Each
segment will be represented by 2 numbers; the
degree of the polynomial (zero) and the coefficient
of the polynomial; thus, for 256 pixels, a total of 6
numbers are required to represent the row. On the
other hand, method 2 can represent the whole row
with just two numbers, a polynomial degree of zero
and the value of the grey scale as the coefficient of
the polynomial.
This is not the only case in which method 2 is
better than Method 1. Method 2 is flexible as when
faced with a sharp edge that may make the segment
non-compressible, it takes a step back to the
previous segment that was compressed without
problems. That is the pixels in the edge part will be
taken at the start of the new segment. In the case of
Method 1, facing an edge that make the segment
non-compressed forces the method to store the
original grey values of the pixels in this segment.
 A "magic number": for identifying the option
of compression. “M1” Option 1, “O2” Option 2
and “O3” Option 3, followed by a white space.
 The width of the image, formatted as ASCII
characters, followed by a white space.
 The height, in ASCII, followed by a white
space.
 The number of pixels in a segment, again in
ASCII decimal. This number is used for the
reconstruction phase of the compressed image.
In the case of Method 3, this number is set to 4.
 The segments are represented sequentially as a
one-dimensional byte array starting from the
first row or first column. There are two ways to
represent a segment.
1. Compressed segment:
o degree
o coefficients (degree+1)
2. Non-compressed segment:
o degree of -1
o A value, of the actual grey scale value
minus 128 (to be stored in a byte), is
stored for each pixel in the segment.
 Characters from”#" to the next end-of-line are
ignored (comments).
3.3 Method 3
This method starts by fitting the whole row as a
segment starting from zero degree and increases the
degree if error is exceeded. If the segment is not
compressed (reached the maximum degree
allowed), then two new segments will be taken
instead. Each new segment has half the number of
pixels in the previous segment. The method will try
to compress each segment. If one segment or both
segments were not compressed, then the process is
repeated for any non-compressed segment in which
the segment will be divided into two segments that
have the same number of pixels. The process is
repeated until reaching the minimum allowed
number of pixels in a segment. The minimum
allowed number of pixels in a segment could be
fixed to 4 or could be made an input value entered
by the user along with the maximum individual
error. Each segment is represented by a byte
followed by the coefficients. The first byte is used
for the degree (in 4 bits) and the number of pixels
as power of 2 (also 4 bits, i.e. if the number of
pixels is 128 then 7 is stored).
3.4 Compressed image format
The compressed image is represented and stored in
a file having the extension “.ch”. The compressed
image is represented as the following:
4 Conclusion
The proposed image compression technique was
tested on a number of test images. The three
options of Method 1 generally produced acceptable
compression ratios (above 2.0) when the default
optional input values were used. The only case
where a low compression was obtained was when a
texture image, Lena as seen in Figure 6.7, was
used. These types of images are considered the
hardest to compress using the implemented system.
It was noted, in general, that higher number of
pixels in a segment results in lower compression
ratio with the quality of the image preserved if the
maximum individual error is fixed. The default
value of the number of pixels in a segment, 16,
gives most of the times the best compression ratio.
On the other hand, increasing the individual error
(with the number of pixels in a segment fixed) led
to an increase in the compression ratio, but the
quality of the image deteriorated. The quality of the
reconstructed compressed image became worse
when reaching high individual error and differences
were clearly seen in the case of maximum
individual error of 15.
The second option of Method 1 was compared
with JPEG compression technique. The two
optional inputs were selected to be 16 pixels in a
segment and a maximum individual error of 10.
The choice was done based on acquiring an
acceptable compression ratio (2.2531), while
keeping the quality of the reconstructed compressed
image acceptable for use. Method 1 gave better
results in the terms of calculated statistics; better
DPP, NCC, EMS, SNR and maximum error.
One major advantage of Method 1 over JPEG is
the ability to control the maximum individual error.
This is clearly evident from Table 1 as the
maximum individual error of Method 1 was 10
(specified maximum individual error), while that of
JPEG was 34 (using quality of 75). To reduce the
error in JPEG to 10 quality 93 was used and then
compression ratio of only 2.5 was obtained.
An application where the errors of the
reconstructed compressed image needed to be
directly controlled and the quality of textured areas
preserved is an ideal one for using this method. In
medical imaging, for example, an error reaching a
value of 34 may result in misinterpretation of the
medical diagnosis obtained from the image.
Another advantage is that this method preserves
the quality of the most difficult parts of the image
that cannot be compressed, as they are stored
without any change (only some pre-processing and
post-processing operations to store the original
values in a byte format).
It was observed that compression ratios obtained
from the three options on the same input image
were not the same (for fixed optional inputs); one
of the three compression ratios is better than the
remaining two with little difference in the other
statistics. As a different image was tested, it was
found that the best compression was not generated
by the same option that generated the previous best
compression. The possibility of one method
producing a better compression than the remaining
two is related directly to the structure or shape of
the input image. For example, for the Lena image
the column option gave slightly better results than
the others because of vertical uniform areas. This
can be considered as an advantage for Method 1.
Also, The compression ratio obtained from
Method 1 can be made better by packing the
degrees of each two consecutive segments into one
byte instead of one byte each. Also, Huffman
coding or other lossless compression techniques
could be used on the compressed file for further
compression.
Method 1 is the basic building block for more
advanced methods. Method 1 operates in a blind
fashion as it will always deal with the compression
of the segments made up by a fixed number of
pixels. This way of compression has its
disadvantage as either the segment will be
compressed or the original pixels are stored (noncompressible segment). This Method is not flexible
as in most cases, crossing a sharp edge, for
example, results in the original pixels being stored.
Note that Method 1 is not as fast as JPEG, but
could be improved by using parallel processing.
This is possible as the method lends itself readily to
parallel processing since it is row or column-based.
However, time to reconstruct the image is very fast.
Finally, with the consideration of Method1 simple
and fixed approach, on average it gave acceptable
compression ratios greater than 2. The other
suggested methods of Chebyshev image
compression (Methods 2 and 3) are expected to
achieve better results. Future publications will
report results of these two new methods.
References:
[1] D.M. Bethel, D.M. Monro, “Polynomial
image coding with vector quantised
compensation”, Proc. ICASSP-95, vol. 4,
2499-2502.
[2] Y. Chee, K. Park, “Medical image
compression using the characteristics of
human visual system”, Proc. 16th Int. Conf. of
the IEEE, Eng. Advances: New Opportunities
for Biomedical Eng.., vol. 1, 618-619, 1994.
[3] F. De Natale, et. al., “Polynomial
Approximation and Vector Quantization: A
Region-Based Approach”, IEEE Trans. On
Communications, vol. 43, no. 2-4, Feb-Apr
1995, pp 198-206.
[4] A. Helzer, et. al, “Using implicit polynomials
for image compression”, Proc. 21st IEEE
Conv. of the EEEI, pp 384-388, 2000.
[5] I. Sadeh, “Polynomial Approximation of
Images”, Computers Math. Applications, vol.
32, no. 5, pp 99-115, 1995.
[6] G. Wallace, “The JPEG Still Picture
Compression Standard”, CACM, vol. 34, pp
33-40, Apr 1990.
[7] M.G. Cox, J.G.Hayes, “Curve Fitting: A guide
and suite of Algorithms for the Non-Specialist
user”, NPL Report NAC 26, Dec 1973.
[8] C.W. Clenshaw, “Mathematical Tables”,
Volume 5, National Physical Laboratory,
London 1962.
[9] “Numerical Recipes in c: The Art of Scientific
Computing”, Cambridge University Press,
1988-1992.
[10] M.J. Zemerly, “A rule-based system for
processing retinal images”, Ph.D. thesis,
University of Birmingham, U.K, August 1989.
Download