An Improved JPEG Compression Algorithm Based on Sloped-facet Model of Image Segmentation Chengyou Wang, Zhengxin Hou, Kai He, Aiping Yang School of Electronic Information Engineering, Tianjin University, Tianjin, 300072, China
[email protected],
[email protected],
[email protected],
[email protected]
Abstract 2. The basic idea of the sloped-facet model This paper proposed an improved JPEG compression algorithm based on Haralick sloped-facet model. Different areas after segmentation were taken into account in this algorithm and different areas are compressed in different proportion. The experiment results show that the quality of reconstructed images is better than the traditional JPEG compression algorithm at the same bit rate about 0.3dB. Keywords: image compression, sloped-facet model, image segmentation, JPEG compression algorithm, Peak Signal to Noise Ratio (PSNR)
1. Introduction In various image coding standards, JPEG (Joint Photographic Experts Group) in [1], [2] as a still image compression standard is extensively used in digital image processing. However, these traditional compression algorithms based on DCT (Discrete Cosine Transform) process the image as a whole directly and different areas of images have not taken into account. Although compression ratio is obtained somewhat, the compression effects of the reconstructed images are not enough well. The reason is that whatever flat areas or edge areas in an image, the same compression scale is used. Considering the drawbacks of these algorithms above, an improved JPEG compression algorithm based on Haralick sloped-facet model in [2] of image segmentation was proposed in this paper. The algorithm regards different areas in images after segmentation and different compression proportions were used correspondingly. Greater compression ratio is gained and the PSNR of the reconstruction images are higher compared with the traditional JPEG algorithm. This paper is organized as follows. Section 2 explains the basic idea of the sloped-facet model. And then In Section 3, image segmentation is introduced. Improved JPEG compression algorithm this paper proposed are fully described in Section 4. In Section 5, experimental results and comparison with JPEG algorithm are given and rate distortion curves are plotted. Some reconstructed images are also displayed. The conclusion of the paper is in Section 6.
The digital image can be described by the function z = f (r , c) , where r , c is the row and column index respectively, and z is the gray value of the point (r , c ) . So an image can be expressed by a gray curve in threedimensional space (r , c, z ) . As for the function f , the restriction is that the domain of f can be partitioned into connected sets S = { S1 , S2 , S3 ,! , Sm } such that for each connected set Si ∈ S . (1) If (r , c) ∈ S , it implies that for some K -pixel neighborhood N containing (r , c) , N ⊆ Si . (2) If (r , c) ∈ Si , it implies that f (r , c) = α i × r + β i × c + γ i (1) Condition (1) requires that connected sets the partition S consists of should be large enough and smooth enough. For example, if K = 9 , the neighborhood we consider is 3 × 3 , then each set Si must be no thinner than 3 × 3 in any place. If Si has holes, they must be surrounded everywhere by pixels in 3 × 3 neighborhoods which are entirely contained in Si . Condition (2) requires that the gray tone surface defined on Si in (r , c, z ) should be a sloped plane. This constraint could obviously be generalized to include higher-order polynomials. The fact that the parameters α and β determine the value of the slope in any direction is well known. For a planar surface of the form f (r , c) = α × r + β × c + γ (2) The value of the slope at an angle θ to the row axis is given by the directional derivative of f in the direction θ . Since α is the partial derivative of f with respect to r and β is the partial derivative of f with respect to c , the value of the slope at angle θ is α cos θ + β sin θ . The angle θ which maximizes this value satisfies α β , sin θ = cos θ = 2 2 2 α +β α +β2
1-4244-1312-5/07/$25.00 © 2007 IEEE
2893
And the gradient which is the value of the slope in steepest direction is fθ = α cos θ + β sin θ =α×
α α +β
this
2
β
+β×
= α +β time, the directional 2
At
2
α +β2 2
2
derivative
has
(3) the
maximum α + β , which is the gradient gradθ . This is the basic idea of the sloped-facet model in [3]. The sloped-facet model is an appropriate one for either the FlatWorld Assumption (FWA) or Sloped-World Assumption (SWA). In the flat world each ideal region is constant in gray, i.e. the gray plane defined by Si parallels the plane rc , and the gray values of all the points in Si are the same constant. In the sloped facet world, each ideal region has a gray tone surface which is a sloped plane, i.e. there is an angle θ between the gray plane defined by Si and the plane rc . According to the sloped-facet model, an image can be divided into many areas which have different size and different shape, and each area corresponding to Si . There are two kinds of points in an image, EP (Edge Point) or RP (Region Point). As an EP, there are several areas in its neighborhood. But as to RP, there is only unitary area. All the points are marked EP or RP after segmentation. 2
2
3. Image segmentation
According to the Least Square Method, we get αˆ = ¦¦ r < f (r , c) / ¦¦ r 2 r∈ R c∈C
βˆ = ¦¦ c < f (r , c ) / ¦¦ c 2 r∈R c∈C
r∈R c∈C
γˆ = ¦¦ f (r , c) / ¦¦ 1
(6)
The error is ε 2 = ¦¦ [α × r + β × c + γ − f (r , c)]2
(7)
r∈R c∈C
r∈ R c∈C
When the value of ε 2 is smaller, it shows that the window is a singularity one. A window belongs to which type depends on the comparison results between ε 2 and T . Besides, the gradient value of the slope at angle θ should be considered too, according to equation (3) and (5), we get grad = αˆ 2 + βˆ 2 (8) θ
When the gradient value of the slope at angle θ is bigger, it shows that the pixels’ value in the window changed much. It is very likely to multiple areas. Likewise, we can determine by setting a threshold Tθ as well. The segmentation flow as follows: if ε 2 > T 2 flag (r , c) =EP(which means edge point) else if gradθ > Tθ flag (r , c) =EP else flag (r , c) =RP(which means region point) The segmentation algorithm in [4] based on the slopedfacet model preserve the edges of images effectively and it does not have pseudo-edges at the areas where pixels’ gray changes gradually.
4. Improved JPEG compression algorithm
Suppose the size of the window is R × C (In this paper, R = 8 and C = 8 ), when (r , c) ∈ R × C , the window can be expressed by the function z = f ( r , c) (4) Suppose to all (r , c ) ∈ R × C , f (r , c) ∈ Si ( Si is a set of S ) comes into existence, that is to say, there is only the singularity area in the window. According to the slopedfacet model, fˆ (r , c ) which is the estimate value of f (r , c ) satisfies equation (1), fˆ (r , c ) = αˆ × r + βˆ × c + γˆ (5)
r∈R c∈C
The value of ε 2 indicates the degree how the window satisfy the hypothesis directly. When the value of ε 2 is bigger, it shows that there is (r , c ) ∈ R × C , which makes f (r , c) ∉ Si . There are several areas in the window.
r∈R c∈C
Just like JPEG algorithm, we suppose images have 256 gray levels. And then each image was separated into many 8 × 8 blocks, where the maximum value of pixels is max and the minimum is min . So the difference between them is dif=max-min . Suppose we have a threshold T1 ( 0