Comparison between CS and JPEG in terms of image compression
The comparison between two approaches, JPEG and Compressive Sensing, is done in the paper. The approaches are compared in terms of image compression. Comparison is done by measuring the image quality versus number of samples used for image recovering…
Authors: Danko Petric, Marija Milinkovic
Comparison betwe en CS and JPEG in terms of image compression Marija Milinkov ić, Danko Petrić University of Mo ntenegro, Faculty of Electric al Engineer ing Podgor ica, Montenegro Abstract —The comparison betw een two approaches, JPEG and Compressive Sensing, is done in the paper. The approaches are compared in terms of i mage compression. C omparison is done by measuring th e image quality versus number of samples used for image rec ov ering. Images are visually compared. Also, nu m erical quality value, PSNR, is calculated and co mpared for the t w o approaches. It is s hown that images, re covered by using the Compressive Sensing approach, have higher PSN R values compared to the images under JPEG compres sion. Difference is larger in grayscale images w ith s ma ll number of details, like e. g. medical images (x-r ay). The theory is supported by t he experimental results. Keywords - Digital image reconstructio n, Compressive Sensing, JPEG compression, Total Variat ion I. I NTRODUCTI ON The Shannon-Nyquist sampling theore m t ells us t hat si gnal can be reconstructed if sampling frequency is at least t wice higher then maximal si gnal frequency [1]. In many applicatio ns, the N yquist freq uency can b e so h igh t hat we end up with too many sa mples and must compress i n or der to store or transmit th em. Therefor e, compression appeared as a necessity in order to ease storing and tra nsmission of the signals. On the other side, durin g the trans mission, sig nal samples can be lo st, or can be corrupted by noise and consider ed as missing. T hese lost o r c orrupted signal val ues ma y be recovered under c ertain cond itions, using the Co m pressi ve Sensing (CS) approa ch [1]-[4]. Depending on the applica tion, different reconstructio n a pproaches are used [5]-[20]. In this paper the comparison i s made bet w een co mmonly u sed i mage compression algorith m, JPEG, and CS approach, having in mind that both disc ard certain si gnal coefficients. Compression algorithms are based on tw o basic presumptions: the imperfectio n of human perception and the specific pro perties of signal in certain transfor m domain s uch as Discrete Fourier Tr ansform ( DFT), Discre te Wavelet Tra nsf orm (DWT ), Discrete Co sine Transform (DCT ), [1] etc. JPEG a lgorithm is co mmonly used for i mage c ompression [1], [21], [22]. By using t he JP EG algorithm, a notab le compression ratio can be ach ieved, keeping high image quality. The standard JPEG algorithm is b ased on the 8×8 image blocks and uses DCT transform. In recent y ears, th e CS approach i s intensivel y st udied. T he goal of this appr oach is to ove rcome the limit s of the Shannon- Nyquist sampling theore m by recovering information about the signal using s mall set o f available signal coefficients. To appl y the CS, a cer tain conditions have to be sa tisfied, that are: rando m distrib ution of the a vailable sa m ples a nd sparse si gnal representation in a c ertain tr ansform domain. Spar se representation mean s that signal, in certain domain, has a small number of nonzero coe fficients in compar ison with the signal length. At the beginnin g, the CS app roach w as used in computed tomography, but later , the a pplication field has gro wn. Ma ny signals ca n be consid ered as s pa rse in certa in transform do main, which makes them suitab le for CS. For exa mple, ISAR i mages are sparse i n t he dom ain of t wo-dimensional DFT, whi le digital image can be co nsidered a s a spar se in the D CT domain. CS approa ch is nowadays used in biomedical and c ommunicatio n signal anal ysis , etc. The pap er is organized in five sectio ns. After Introd uction, in Sect ions II and III b asic infor mation about JPEG and Compressive Se nsing are p rovided. Sec tion IV includes results of comparison and finall y, p aper is finished with concludi ng remarks in Sect ion V. II. JPEG C OMPRESS I ON JPE G compression algorith m uses image blocks of 8×8 size. After ima ge divid ing, a DCT transfor m of current image block is perfor med. DCT is defined b y [1]: 7 7 1 2 1 2 1 2 i 0 0 2 1 2 1 ( ) ( ) , , 2 2 1 6 1 6 j i k j k C k C k D C T k k a i j c o s s in (1) Where: 1 1 1 1 , for 0 2 1 , for 0 k C k k 2 2 2 1 , f or 0 2 1 , fo r 0 k C k k (2) and a(i,j) denotes a pixel of t he original image. T ransform coefficients are quantized using the qua ntization matrix. T his matrix is calculated based o n the co mpression quality that we want to a chieve. After quanti zation, i.e. dividing DCT m atrix with q uantization matrix, coe fficient a t p osition (0,0 ) is called DC component. The rest coefficie nts are the A C c omponents. DC represents the mea n value of all coefficient s in block. Quantization matri x is calc ulated b y using the follo wing relation: 50 ( ) QF rou nd q Q Q (3) Where: 2 0 . 0 2 f o r 5 0 5 0 f o r 5 0 Q F Q F q Q F Q F (4) QF represents quality facto r and Q 50 is quantization matri x that is experimental ly obtained. Ma trix Q 50 is shown in Fi g. 1. 16 11 10 16 24 40 51 61 12 12 14 19 26 58 60 55 14 13 16 24 40 57 69 56 14 17 22 29 51 87 80 62 18 22 37 56 68 109 103 77 24 35 55 64 81 104 113 92 49 64 78 87 103 121 120 101 72 92 95 98 112 100 103 99 Figure 1: Coefficients of the qu an tization matrix Q 50 Quantization is a pplied: 1 2 1 2 1 2 , , , q D C T k k D C T k k r o u n d Q k k (5) Matrix is then reordered in zigzag manner. AC components are coded using the Huffma n Coding Ta ble. This part of al gorithm is lossless. Quantization will leave us with matrix that has many zeros a nd coefficients mo stly in the lo w frequenc y area with DC component at ( 0,0). At the dec oder side, the inverse 2D DCT transfor m is applied: 2 7 7 1 2 1 1 2 0 0 ( ) ( ) (2 1 ) 1 6 (2 1 ) ( , ) ( , ) 2 1 6 2 d q i j C k C k i k j k a i j D C T k k c o s s in (6) Where 1 2 ( , ) dq DCT k k is dequantized DCT matrix: 1 2 1 2 1 2 ( , ) ( , ) ( , ) dq q DC T k k D CT k k Q k k (7) We get the rec onstructed image with an error p roportional to the quantizatio n step [1]. The are a of interest for JPE G com pres sion in this paper i s after lossy part of JPEG Encode r sho wn i n Fig. 2. Entrop y coding and later decoding w as not n ecessar y for co m parin g a lgorithms. That being said, we needed pro gram for first thr ee blocks o f Fig. 2. Qua ntization was i mplemented the way it is explai ned in this section for different QFs. T hen number of non-zero coefficients is calc ulated for ever y DCT block. With thi s we knew ho w many DCT c oefficient in CS proced ure to p ut to z ero and w e were r eady to compare performances of CS and JPEG in ter ms of i mage co mpression for the same n um ber of non-zer o coefficients. Figure 2. JPEG Encoder Block Schem atic III. C OMPRESSIV E SENSING During the rec ent years of inte nsive research in t he areas o f CS, many different reconst ruction approaches have been developed [1]-[20]. In order to be successfully reconst ructed, signal needs to meet two i mportant co nditions. First, signal should have small number of nonzero samples in certain domain. This p roperty is calle d sp arsity. If a signal meets t his condition the n we can sa y that it has 𝐾 << 𝑁 non-zero coefficients, where K is the n um ber of sig nal co mponents a nd N is the s ignal length. Second condition is the incoherence. I t assumes that si gnal is rich of samples in original domain so that we can collec t enough informatio n about signal [1 ]. The CS pr ocedure wi ll b e sho rtly described in the seque l. Using r andom measurement matrix , M N Φ , the set of rando m measure ment a re s elected f r om t he signal f of lengt h N . Parameter M defines number of m ea surements taken in random manner. T he measurement vec tor y can be defined as: y Φf . (8) Signal f has its cou nterpart in t ransform do main, vector x : f x , (9) where , N N is orthogonal basis matrix. Co mbining the se two equations, we obtain the fo llowing relation: y = ΦΨ x = A x , (10) where A i s the CS matrix of size (𝑀, 𝑁 ). The relation (10) is a n undetermined system of eq uations. The aim i s to solve M linear equations with N unknowns and it is done by using th e optimization algor ithms. T here are many a lgorithms that are formed for this purpose, and all of them can be classified in the following cate gories: l1 mini mization, greedy a lgorithms and total variation (T V) minimizati on. In Fig. 3 [ 1], we can see illustr ation of CS concept where white fields repr esent zeros, i. e. missing coefficie nts. Figure 3: Illustration of the CS co ncept For image reconstructio n, t he Total Variation (TV) minimization is used. To tal Variation of image x represents the sum o f the gradie nt mag nitudes at each point a nd c an be approximated as [1]: , 2 , TV ( ) i j i j a D x (11) Where gradie nt for pixel at po sition ( i , j ) is defined as: i , j ( 1 , ) ( , ) ( , 1 ) ( , ) x i j x i j D a x i j x i j (12 ) Quality of reconstruction is measured by co mparing PSNR(dB) of reconstructed images. PSNR is acronym of Peak to S ignal to Noise Ratio. Mathematical de finition is [3]: m ax 10 1 1 2 ori g rec 0 0 PS N R 10 l og 1 ( , ) ( , ) M N i j Q x i j x i j M N , (1 3) where x orig and x rec are origina l and rec onstructed images, M and N d imensions o f x a nd Q max is maximal brightne ss of the image. IV. R ESULT S I n this sectio n we will pr esent t he r esults obtai ned by reconstructin g i mages “lena.j pg” and “shepp-loga n.png” using algorithms ex plai ned in previous sectio ns. The g oal i s to compare the co mpression performance o f t wo o bserved approa ches, CS and JPEG. The o riginal images are shown in Fig. 4. T he procedure consists of three steps: 1. J PEG compression with differ ent co mpression r atio. Compression r atio (q uality fac tor, QF) is cha nged fro m 10 t o 90 with a step of 10 . Calculation of t he PSNR. 2. CS re construction using diffe rent number of missing image coefficients. It is imp ortant to note that we obser ved certain percentages of t he missing sa mples. T he nu mber of missing s amples is chosen to c orre spond to the number o f z eros in t he 2D DCT d omain, left a fter the quantizat ion i n JPE G proced ure. Calculation of the PSNR. 3. Comparison of the PSN Rs, after JPEG compression and CS-based i mage re construction. T he c omparison i s d one for the same per centage of discar ded samples in both ap proache s. In Fig. 5 the values of PSNR(dB) for bo th observed images are s hown. In Fig. 8. the reconstr ucted/compressed images of shepp- logan.png are shown. Number of non-zero sam ples is 3.45, 7.46, 10.9 %, resp ectiv ely. Fig. 9. shows the reconstruction/co mpression results o f lena.j pg i mage. Number of non-zero samples is 5 .52, 12 .8, 18.4, 31. 1 %, respe ctively, for both conside red appro aches – JPEG and CS. Figure 4. Original I mag es T ABLE I: PSNR VS NUMBER OF NONZERO SAMPLES USED IN JPEG AND CS APPROA CHES QF SAMPL ES [%] PSNR[dB] JPEG PSNR[dB] CS lena.jpg Shepp- logan.png lena.jpg Shepp- logan.png lena.jpg Shepp- logan.png 10 5.52 3.45 28.19 26.13 24.33 25.72 20 8.84 5.11 30.59 27.92 25.87 31.99 30 10.9 6.41 31.92 29.42 26.76 36.96 40 12.8 7.46 32.93 30.67 27.56 42.87 50 14.4 8.36 33.86 31.81 27.95 47.54 60 17.1 9.47 34.76 33.09 28.85 52.46 70 18.4 10.9 36.12 35.05 29.22 54.57 80 27.5 12.8 37.93 37.97 31.66 58.73 90 31.1 15.8 50.32 43.36 32.57 61.09 Figure 5. Le na and Shepp-Logan reconstr uction PSNR(dB) (CS and JPEG ) Figure 6. PSNR(dB) vs number of no n-zero samples in Shepp-Lo gan reconstruction Figure 7. PSNR(dB) vs number of no n-zero samples in Lena reconstruction Based on the obtained results, the follo wing ca n be c oncluded: when cons idering natural images a s lena.jp g , a slightl y better results are obtained b y u sing the JPEG com pression c ompared to the CS. T his c an b e explained by the fact that, in J PEG, certain percent of low-freque ncy coe fficients are used, which may not be the case in CS. CS rando m ly selec ts coeffici ents from all frequency pla ne. When considering the M RI images, that generally have less detail s compared to the natural images, the higher P SNR is obtained i n CS compressio n. Figure 8. Reconstru cted images “s hepp-logan.png”. First row – CS; Second row – JPEG; Figure 9. Reconstru cted images “le na.jpg”. First row – CS; Second row – JPEG; V. C ONCLUSION The comparison betwee n JPEG and CS in terms of image compression is d one in t he paper. Percentage o f m issing samples in CS scenario correspo nds to the number of nonze ro coefficients, left in 2D DCT dom a in after the quantizatio n with different quantization matrices in J PEG. T he comparison is done in ter ms of PSNR value. The simpler i mages, s uch as MRI images, need l ess availab le (nonzero) samples to be reconstructed, compared to the nat ural i mages. T his i s ex pect ed because simpler images, in t ra nsform ba sis, have better spar sity than r eal images. T herefore, the CS i s bet ter solution when considering MRI i mages c ompression. Ho wever, the JPEG shows better performance in natural images d ue to the fac t that natural i mages have more details a nd less spar sity in tra nsform domain. Also, JPEG uses c ertain percent o f lo w i mage coefficients fro m transfor m do m ain, t hat keep imp ortant information about t he image. R EFERENCES [1] S. Stanković, I . Orović, E. Sejdić, „Multimedia Si gnals and Systems“, Basic and A dvanced A lgorithms for Signal Processing, Second Edition, Springer 2015 [2] E. J. Candes, M. B. Wakin, “ An Introduction T o Compressive Samp ling,” Signal Processing Mag azine, IEEE , vol . 25, no. 2, pp. 21, 30, 2008. [3] D. Donoho: "Compressed sensing," I EEE Trans. on Info rmation Theory, 2006, 52, (4), p p. 1289 – 1306 [4] M. Elad, Sparse and Redundant Represe ntations: From Theory to Applications in Sig nal and I mage Processing, Springer 2010. [5] M. Medenica, S. Zuković, A. Dr aganić, I. Orović, S. Stanković, Comparison o f t he alg orithms fo r CS image reconstruction, I n formacione tehnologije IT’14. [6] S. Stankovic, I . Orovic, “An Ideal OMP b ased Comple x-Time Distribution,” 2n d Mediterranean Conference on Embedded Computing MECO - 2013, pp. 109-112, June 2013, B u dva, Monte negro , 2013. [7] E. C andes, J. Romberg, “l1-magic: Recovery of Sparse Signals via Convex Prog ramming”, October 200 5. [8] LJ. Stankovic, S. Stankovic, M. Amin, “Missing Samples Analysis in Signals for Applications to L-estimation and Compressive Sensing,” Signal Processing , vol . 94, Jan 2014, pp. 401-408, 2 013. [9] A. Draganic, I . Orovic, S. Stankov ic, X. Zhang, X. Wang, "Compressive Sensing Approach in the T able Grap e C old Chain Logistics," 6th Mediterranean Confere nce on Embed ded Computing, ME CO 2017. [10] X. Yuan, R. Haimi-Cohen, “ I ma ge C ompression Based on Compressive Sensing, End-to-E nd Comparison wit h JPEG,” 2017, [11] A. Draganić, I .Orović, S. St anković, “ Compressive Sensing Le a st Square problem solution suitabl e for implementation”, 23rd T elecommunications Forum, TELF OR 2015. [12] M. L ust ig, D. L . Donoho, J. M. Santos, J. M. Pauly, “Compresse d S ensing MRI,” IEEE Signal Pro cessing Magaz i ne, March 2008. [13] B. Lutovac, M. Dakovic, S. Stanković, I . Orović, Watermark Detection in I mp ulsive Noise Environment Based on t he Com pressive Sensing Reconstruction, Radioe ngineering, v ol. 26, no. 1, pp. 309- 3 15. [14] I. Orovic, A. Draganic, S. Stankov ic, "Compressive Sensing a s a Watermarking Attack," 2 1st Tele c ommunications Forum TELFOR 2 013,. [15] J. Music, I. Orovic, T. Marasovic, V. Pa pic, S. Stankovic, "Gradient Compressive Sensing for Im age Data Reduction in UAV based Search and Rescue in the Wild," Mathematical Problems in E ngineer ing, Volume 2016 (2016) . [16] J. Music, T. Marasovic, V. Papic, I . Orov ic, S. Stankovic, "Perfo rmance of compressive sensing i mage reconstruction for search and re scue," I EEE Geoscience and Remote Sensing L etters, vol. 13 , Issue: 1 1, p p. 1739 - 1743, November 2 016. [17] J. Romberg , “Imaging via Compressive Sampling,” Signal Processing Magazine, I EEE , vol. 25, no. 2, pp. 1 4, 20, March 20 08. [18] A. Draganic, M. Maric, I. Orovic, S. Stankovic, "I dentification of Image Source Using Serial Num ber Based Watermarking under Compressive Sensing Conditions," 40th Internation al C onvention o n I n formation and Communication Technology , Electronics and Microelectronics, MIPRO 2017. [19] L. C. Potter, E. Ertin, J. T. Parker, M. Cetin, "Sparsity and Compre ssed Sensing i n Radar Imaging," Pro ceedings of the IEEE, vol. 98, no.6, pp.1006-1020, Ju ne 2010. [20] M. Daković, LJ. Stanković, S. Stankov ić, “Gradient Alg orithm Based ISAR I ma ge R econstruction From the I n complete Data set,” 3rd International W orkshop on Compres sed Sensing The ory and its Applications to Ra dar, Sonar and Remote Sensing (CoSe Ra) 2015 [21] J. Miano, Comp res sed Imag e File F ormats: JPEG, PNG, GIF, XBM, BMP, ACM Press, 1999. [22] S. Stankovic, I. Orovic, N. Zaric, "Robust watermarking procedure based on JPEG-DCT image compression," Jo urnal of Electronic I maging, Vol. 17, No. 4, Page (s) 043001, 200 8
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment