Sunteți pe pagina 1din 12

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

WILP S2-11_EAZC473 Forums General Discussion Forum lossless image compression

lossless image compression


by KALLURI RAJESH . - Monday, 2 April 2012, 04:53 PM

Friends, There is a repeated question in old question papers to apply lossless image compression on a table using predictor p6. I wasted around 3 hours to find some worked out solution but in vain ... if any body have some link please share with me ... Any body can solve the problem apply lossless image compression using predictor 6 for the table 10 10 15 10 15 20 15 20 25

Please solve ... its very imp guyz ...


Reply

Re: lossless image compression


by KALLURI RAJESH . - Tuesday, 3 April 2012, 12:29 PM

any inputs ?
Show parent | Reply

Re: lossless image compression


by SRIRAM R . - Tuesday, 3 April 2012, 12:40 PM

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4735 follow this forum, should be the same way i guess !!!
Show parent | Reply

Re: lossless image compression


by ABHAY DUTT PAROHA . - Tuesday, 3 April 2012, 01:02 PM

As per my understanding This question is related to lossless mode of JPEG (different from baseline JPEG). Steps to follow

1 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

1. Predictor 2. Entropy Encoding Predictor 1. For each pixel a predictor (one of 7 possible) is used that best predicts the value contained in the pixel as a combination of up to 3 neighbouring pixels. 2. The difference between the predicted value and the actual value (X) contained in the pixel is used as the predictive difference to represent the pixel. 3. The predictor along with the predictive difference are encoded as the pixel's content. 4. The series of pixel values are encoded using Huffman Coding. P1 P2 P3 P4 P5 P6 P7 A B C A+B+C A+floor[(B-C)/2] B+floor[(A-C)/2] floor[(A+B)/2]

Structure (pixel structure) P P P P P PPPP CBPP AXPP PPPP PPPP

A. The first pixel (0,0) will always use itself. B. Pixels at the first row always use P1. C. Pixel at the first column always use P2. D. The best of the 7 predictions is always chosen for any pixel So our image would be after predictor P6 (I am not sure about this...please verify once) P6 = B+floor[(A-C)/2] 10 10 10 10 10 17 10 17 22

then use entropy coding. Hope, I am clear.


Show parent | Reply

Re: lossless image compression


by KALLURI RAJESH . - Tuesday, 3 April 2012, 02:12 PM

Abhay, thank you ... i understand the procedure but only lack of confidence ... thats why i posted ... now i feel i am in correct line .. @sriram This is different sriram ...

2 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

Show parent | Reply

Re: lossless image compression


by ABHAY DUTT PAROHA . - Tuesday, 3 April 2012, 02:23 PM

Hey Rajesh...I am not sure..same case with me also.. ..lack of confidence...Can u pls verify my procedure......Can u post some steps of Entropy Encoding after this? I think, we cant apply entropy coding (which we use with DCT based compression) because that encoding use DC (predictive difference) and AC coefficients (Run length coding)
Show parent | Reply

Re: lossless image compression


by SRIRAM R . - Tuesday, 3 April 2012, 02:50 PM

Thank God. Guys i owe u all a drink !!


Show parent | Reply

Re: lossless image compression


by ABHAY DUTT PAROHA . - Tuesday, 3 April 2012, 03:23 PM

Hey Sriram... Can u explain

...

entropy coding (which we use with DCT based compression) for lossless JPEG ?
Show parent | Reply

Re: lossless image compression


by TORTHI SUSMITHA . - Tuesday, 3 April 2012, 03:37 PM

I suppose, we have to find out the difference matrix between the original matrix and the matrix obtained after applying prediction, find out the frequency of the characters in the resultant matrix and just apply huffman coding on that. Correct me if i am wrong.
Show parent | Reply

Re: lossless image compression


by KALLURI RAJESH . - Tuesday, 3 April 2012, 05:21 PM

@torthi process is correct ... but here confusion is how to calculate the predicted matrix ... please share if you know @abhay i also got the same answer ... As per my understanding no need to apply any dc encoding ... but for ac coefficients, we can do zigzag scan and apply run length encoding (as said in text book ... i did not remember the procedure) ...

3 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

Show parent | Reply

Re: lossless image compression


by TORTHI SUSMITHA . - Tuesday, 3 April 2012, 07:48 PM

Okay. Here is my understanding.. We need to apply lossless image compression using P6 on the below matrix 10 10 15 10 15 20 15 20 25 For P-6 predictor, the prediction is B+(A-C)/2 Neighboring pixels in a lossless JPEG are assumed to be as given below ---|---|---|---|--| |C|B| ---|---|---|---|--| |A|X| ---|---|---|---|--So if you want to predict value for an element at X, we consider its neighboring pixels in the above form Now, in the matrix, say M, given, 10 10 15 10 15 20 15 20 25 If you consider element at (0,0) no A,B,C exists... hence this value doesnt change for element at (0,1) -> A=10, B and C dont exist --> apply the formula B+(A-C)/2, X value is 10/2=5 (0,2) -> A=10, B and C dont exist -> X=10/2 = 5 For elements at position (1,0) (2,0) (1,1) (1,2) 17.5 (2,1) (2,2) 22.5 -> -> -> -> A and C don't exist, B=10 -> X=10 A and C don't exist, B=10 -> X=10 A=10, B=10, C=10 -> X= 10 + (10-10)/2 = 10 A=15, B=15, C=10 -> X= 15 + (15-10)/2 = 15 + 2.5 =

-> A=15, B=15, C=10 -> X= 15 + (15-10)/2 = 17.5 -> A=20, B=20, C=15 -> X= 20 + (20-15)/2 = 20 + 2.5 =

So the predictor matrix , say P, will be 10 5 5 10 10 17.5

4 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

10 17.5 22.5 Now, my understanding is, we have to find the difference between M and P M-P gives, (not sure whether floor / ceil function is needed for decimal values) 0 5 10 0 5 2.5 5 2.5 2.5 and, we have to apply Huffman coding on the above matrix, considering the frequency of each character. 0 --> freq = 2 5 --> freq = 3 2.5 --> freq = 3 10 --> freq = 1 I am not confident about the above step.. someone please confirm !! This is my understanding--- please let me know if i didnot understand the algorithm properly
Show parent | Reply

Re: lossless image compression


by ABHAY DUTT PAROHA . - Tuesday, 3 April 2012, 11:40 PM

We need to apply lossless image compression using P6 on the below table - M 10 10 15 10 15 20 15 20 25 For P-6 predictor, the prediction is B+floor[(A-C)/2] ---|---|---|---|--||C|B| ---|---|---|---|--||A|X| ---|---|---|---|--Rules are below (I think, we need to apply below rules during our calculations) A. The first pixel (0,0) will always use itself. B. Pixels at the first row always use P1. C. Pixel at the first column always use P2. D. The best of the 7 predictions is always chosen for any pixel P1 A P2 B

5 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

P3 P4 P5 P6 P7

C A+B+C A+floor[(B-C)/2] B+floor[(A-C)/2] floor[(A+B)/2]

So, the Predicator Table is - P 10 10 10 10 10 17 10 17 22 Difference : M-P 005 053 533 Huffman Coding Count(0) = 3 Count(3) = 3 Count(5) = 3 Torthi..Can you please confirm? (I used rules also, that's why I am getting different matrix for P)
Show parent | Reply

Re: lossless image compression


by TORTHI SUSMITHA . - Wednesday, 4 April 2012, 12:17 AM

Hi, Are you sure we have to apply P1 and P2 on first row and first column always ??? I was in an assumption that when P-6[=B+(A-C)/2] is used, for first row , the predicted values will be A/2 for first column, the predicted values will be B (u can say P2) this is wat i understood from the text book.. Please share the source where these rules are mentioned.. i haven't come across anything like this in the text book... or not sure if i had missed that point... Also, are you sure, we have to use the FLOOR of the value ?? btwn... i m Susmitha, Torthi is my surname.. ;)

Show parent | Reply

6 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

Re: lossless image compression


by ABHAY DUTT PAROHA . - Wednesday, 4 April 2012, 09:45 AM

Hi Sushmitha, I was assuming ur name as Torthi.. Here are the links Simon Fraser University Lectures http://www.cs.sfu.ca/CourseCentral/365/mark /material/notes/Chap4/Chap4.2/Chap4.2.html http://www.ecpe.nu.ac.th/paisarn/Multimedia/week2 /M4L1.pdf http://www.technicaljournalsonline.com /jers/past%20issue/swapnillahudkar.pdf http://www.cs.clemson.edu/~jzwang/1201863 /cpsc86303.pdf Can you please mention the text book where you read this? I am 100% sure about FLOOR value..
Show parent | Reply

...

Re: lossless image compression


by TORTHI SUSMITHA . - Wednesday, 4 April 2012, 09:50 AM

Cool... thanks a lot for the info... i was referring to T1 - prescribed text book.. not sure if these points were mentioned there.. i dont remember reading these rules in the text book..

Show parent | Reply

Re: lossless image compression


by ABHAY DUTT PAROHA . - Wednesday, 4 April 2012, 10:21 AM

I came across one example also Source Image and video compression standards: algorithms and architectures By Vasudev Bhaskaran, Konstantinos

Konstantinides

7 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

Concept The prediction residual is computed modulo 2 power 16. The residual is not directly Huffman Coded. Instead, it is expressed as pair of symbols : the category and the magnitude. 1. The first symbol represents the number of bits needed to encode the magnitude. (Only this value is Huffman coded) Example: Prediction value for X is 42, then from table (see at last), we determine that this value belongs to category 6, that is we need an additional 6 bits to uniquely determine the value 42. 2. The prediction residual is then mapped into 2 tuple (6, 6 bit code for 42) 3. Category 6 is Huffman Coded and the compressed representation for the prediction residual consists of this Huffman codeword followed by this 6 bit representation for the magnitude. 4. If the value of residual is positive: then code for magnitude is its direct binary representation. 5. If the value of residual is negative: then code for the magnitude is one's complement of the absolute value Consider ---|---|---|---|--||C|B| ---|---|---|---|--||A|X| ---|---|---|---|--Pixel values A=100, B=191, C=100 and X=180. Let Y = (A+B)/2; (which comes 145.5, but because we are using FLOOR, this will become 145) and the prediction residual is r = 145 - 180 = -35. From Table , belongs to category 6.The binary number for 35 is 100011, and its one's complement is 011100. Thus, is represented as(6,011100). If the Huffman code for six is 1110, then is coded by the

8 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

10-bitcodeword 1110011100. Without entropy coding, would require 16 bits. In the decoder, the category (that is, 6) is extracted first.Thus, the next six bits, 011100, correspond to the magnitude of the residual.Since the most significant bit is zero, the residual is negative. After takingthe one's complement of 011100, the decoded value of the residual r is -35 . The A and B bits have already been decoded; thus Y = 145, as before, and X = Y+35 = 180 Category Prediction Residual

0 1 2

0 -1, 1 -3, -2, 2, 3

3 4 5

-7, , -4, 4, , 7 -15, , -8, 8, , 15 -31, ,-16, 16, , 31

6 7 8

-63, , -32, 32, , 63 -127, ..., -64, 64, , 127 -255, ..., -128, 128, ..., 255

9 10 11

-511, ..., -256, 256, ..., 511 -1023,..., -512, 512, ..., 1023 -2047, ..., -1024, 1024, ..., 2047

12 13

-4095, ..., -2048, 2048, ..., 4095 -8191, ..., -4096, 4096, ..., 8191 -16383, ,-8192, 8192, ..., 16383

14

9 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

15

-32767, ..., -16384, 16384, ..., 32767

16

32768

Table: Prediction residual categories forlossless JPEG compression.


Show parent | Reply

Re: lossless image compression


by TUSHAR PAWAR . - Tuesday, 3 April 2012, 06:41 PM

Abhay thanks for solution can u pls explain how u get 17 and 22 after using p6 formula 10 10 10 10 10 17 10 17 22
Show parent | Reply

Re: lossless image compression


by ABHAY DUTT PAROHA . - Tuesday, 3 April 2012, 11:42 PM

Hey Tushar...see my solution above ur post...


Show parent | Reply

Re: lossless image compression


by SHETH TEJAS NIXIT . - Wednesday, 4 April 2012, 08:17 PM

thnaks abhay.. post was very helpfull


Show parent | Reply

Re: lossless image compression


by SARANG PADMAKAR GAIKI . - Tuesday, 3 April 2012, 11:47 PM

Hello All Thanks for this.Even I was searching for such problems.However I have not understood the concepts. Can some one tell me the source for this.Have you gone thru lectures or it is better illustarted in book.Please let me know. Regards Sarang
Show parent | Reply

Re: lossless image compression


by KALLURI RAJESH . - Wednesday, 4 April 2012, 10:33 AM

10 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

abhay, thank you ... I am having only one doubt in the solution about this point ... Point says "it uses only previously encoded neighbors, the very first pixel I(0, 0) will have to use itself. Other pixels at the first row always use P1, at the first column always use P2." By this point ... do we have to apply the formula on predicted values or original values ? In the solution , We are doing on original values only ...
Show parent | Reply

Re: lossless image compression


by ABHAY DUTT PAROHA . - Wednesday, 4 April 2012, 10:41 AM

You will apply the formula on original values only. After that, you will get one differt matrix. After this, you need to calculate predictive residuals matrix
Show parent | Reply

Re: lossless image compression


by DHEERAJ SHARMA . - Wednesday, 4 April 2012, 11:00 AM

Appreciate your efforts for explanation Abhay.


Show parent | Reply

Re: lossless image compression


by RAMYA N . - Wednesday, 4 April 2012, 03:07 PM

Thanks a lot Abhay...


Show parent | Reply

Re: lossless image compression


by PANKAJ RAWAL . - Wednesday, 4 April 2012, 11:10 PM

Hi Abhay, If we need to apply formula only on original values. Then Value @ (0,2) i.e last row first column should apply P2->B prediction so its value as per original values should come as 15 and not 10. Please let me know if i am missing anything. Final result 10 10 10 10 10 17 15 17 22
Show parent | Reply

11 of 12

05-04-2012 02:28

S2-11_EAZC473: lossless image compression

http://taxila.bits-pilani.ac.in/mod/forum/discuss.php?d=4734

An institution deemed to be a University estd. vide Sec.3 of the UGC Act,1956 under notification # F.12-23/63.U-2 of Jun 18,1964 2011-2012 Centre for Software Development,SDET Unit, BITS-Pilani, India. Contact us : taxila@bits-pilani.ac.in

Powered by Moodle

12 of 12

05-04-2012 02:28

S-ar putea să vă placă și