reset password
Author Message
amir309
Posts: 4
Posted 20:38 May 12, 2011 |

 

I think my DCT and Quantization  parts are working fine and i have this output for the Ducky image:

S=1638000 bits

n=0 :      D = 66804 bits     ,CR = 24.51948985090713

n=1:       D = 63462 bits      ,CR = 25.810721376571806

n=4:       D = 51666 bits      ,CR = 31.70363488561143

n=5:       D = 46774 bits      ,CR = 35.01945525291829

I am not sure if it is correct or not but i think i am close......

cbort
Posts: 95
Posted 20:58 May 12, 2011 |

See below

Last edited by cbort at 01:17 May 13, 2011.
cbort
Posts: 95
Posted 21:04 May 12, 2011 |

or make a red 64x64 image... what is your S/D for those?


For a quantization level n = 0
The original image cost, (S), is 98304.0 bits.
The Y values cost is 1536.0 bits.
The Cb values cost is 352.0 bits.
The Cr values cost is 352.0 bits.
The total compressed image cost, (D), is 2240.0 bits.
The compression ratio, (S/D), is 43.885714285714286.


For a quantization level n = 1
The original image cost, (S), is 98304.0 bits.
The Y values cost is 1408.0 bits.
The Cb values cost is 320.0 bits.
The Cr values cost is 320.0 bits.
The total compressed image cost, (D), is 2048.0 bits.
The compression ratio, (S/D), is 48.0.


For a quantization level n = 2
The original image cost, (S), is 98304.0 bits.
The Y values cost is 1280.0 bits.
The Cb values cost is 288.0 bits.
The Cr values cost is 288.0 bits.
The total compressed image cost, (D), is 1856.0 bits.
The compression ratio, (S/D), is 52.96551724137931.


For a quantization level n = 3

The original image cost, (S), is 98304.0 bits.
The Y values cost is 1152.0 bits.
The Cb values cost is 256.0 bits.
The Cr values cost is 256.0 bits.
The total compressed image cost, (D), is 1664.0 bits.
The compression ratio, (S/D), is 59.07692307692308.

For a quantization level n = 4
The original image cost, (S), is 98304.0 bits.
The Y values cost is 1024.0 bits.
The Cb values cost is 224.0 bits.
The Cr values cost is 224.0 bits.
The total compressed image cost, (D), is 1472.0 bits.
The compression ratio, (S/D), is 66.78260869565217.

For a quantization level n = 5
The original image cost, (S), is 98304.0 bits.
The Y values cost is 896.0 bits.
The Cb values cost is 192.0 bits.
The Cr values cost is 192.0 bits.
The total compressed image cost, (D), is 1280.0 bits.
The compression ratio, (S/D), is 76.8.

amir309
Posts: 4
Posted 23:06 May 12, 2011 |

Hey CBORT, I changed some parts and my output was pretty close to yours. Base on that i think the difference is because of the numbers of (code, run-length) pairs that we find in the blocks. I don't know which on is possibility correct but i feel like my first result more.   

lma12
Posts: 13
Posted 23:39 May 12, 2011 |

 

Ducky:
 
n=0:
# of Y blocks = 1120, # of bits for Y = 132645
# of Cb blocks = 288, # of bits for Cb = 27602
# of Cr blocks = 288, # of bits for Cr = 19034
S=1638000, D=179281, CR=9.14
 
n=1:
# of Y blocks = 1120, # of bits for Y = 89096
# of Cb blocks = 288, # of bits for Cb = 17187
# of Cr blocks = 288, # of bits for Cr = 12910
S=1638000, D=119193, CR=13.74
 
n=2:
# of Y blocks = 1120, # of bits for Y = 61582
# of Cb blocks = 288, # of bits for Cb = 11268
# of Cr blocks = 288, # of bits for Cr = 8988
S=1638000, D=81838, CR=20.02
 
n=3:
# of Y blocks = 1120, # of bits for Y = 43020
# of Cb blocks = 288, # of bits for Cb = 8403
# of Cr blocks = 288, # of bits for Cr = 6434
S=1638000, D=57857, CR=28.31
 
n=4:
# of Y blocks = 1120, # of bits for Y = 30130
# of Cb blocks = 288, # of bits for Cb = 5782
# of Cr blocks = 288, # of bits for Cr = 4342
S=1638000, D=40254, CR=40.69
 
n=5:
# of Y blocks = 1120, # of bits for Y = 20760
# of Cb blocks = 288, # of bits for Cb = 3834
# of Cr blocks = 288, # of bits for Cr = 3492
S=1638000, D=28086, CR=58.32
Last edited by lma12 at 20:07 May 16, 2011.
amir309
Posts: 4
Posted 23:54 May 12, 2011 |

 

Here is my output for 64*64 red image. 

S=98304 bits

n=0 :      D = 2240 bits     ,CR = 43.885714285714286

n=1:       D = 2048 bits      ,CR = 48.0

n=4:       D = 1472 bits      ,CR = 66.78260869565217

n=5:       D = 1280 bits      ,CR = 76.8

then ether both of us are right or wrong. 

let's check Dune image. Here is my output for the Dune image:

 

S=2457600 bits

n=0 :      D = 154579 bits     ,CR = 15.898666701168981       Y=118695   Cr=17186   Cb=18698 

n=1:       D = 108175 bits      ,CR = 22.718742777906172     Y=82828   Cr=12199   Cb=13148  

n=4:       D = 43762 bits      ,CR = 56.15831086330606     Y=31892   Cr=5820   Cb=6050

n=5:       D = 34281 bits      ,CR = 71.68985735538637     Y=24420   Cr=4917   Cb=4944


cbort
Posts: 95
Posted 00:28 May 13, 2011 |

 

for waterfall QuantizedYs[9][9]:

  -72    -7    -2    -1     0     0     0     0
   -1     8    -8    -1     0     0     0     0
   -8    12     1    -2    -1    -1     0     0
   -4     1     2     0     0     0     0     0
    1     1     0     1     0     0     0     0
    0     0     1     0     0     0     0     0
    0     0     0     0     0     0     0     0
    0     0     0     0     0     0     0     0

Encoded values
(Value, runlength)
NOTE #1. is the DC...

  1. (-72.0, 0.0)
  2. (-1.0, 1.0)
  3. (-7.0, 1.0)
  4. (-2.0, 1.0)
  5. (8.0, 1.0)
  6. (-8.0, 1.0)
  7. (-4.0, 1.0)
  8. (12.0, 1.0)
  9. (-8.0, 1.0)
  10. (-1.0, 1.0)
  11. (0.0, 1.0)

Encoded values continued

 13.   (-1.0, 1.0)
14.   (1.0, 3.0)
15.   (0.0, 1.0)
16.   (1.0, 1.0)
17.   (2.0, 1.0)
18.   (-2.0, 1.0)
19.   (0.0, 4.0)
20.   (-1.0, 1.0)
21.   (0.0, 6.0)
22.   (1.0, 2.0)
23.   (0.0, 1.0)
24.   (-1.0, 1.0)
25.   (0.0, 30.0)

 



 

My answer was incorrect before for all cases that were not 1 solid color. My new answer however is not equal to yours and I traced my quantized block and what it encoded, so I am fairly certain it is right now... Try doing the same thing and see if your trace goes zigzag like it is supposed to

 

 

Last edited by cbort at 01:27 May 13, 2011.
cbort
Posts: 95
Posted 01:29 May 13, 2011 |

DUCKY.PPM

For a quantization level n = 0
The original image cost, (S), is 1638000.0 bits.
The Y values cost is 133140.0 bits.
The Cb values cost is 30276.0 bits.
The Cr values cost is 21358.0 bits.
The total compressed image cost, (D), is 184774.0 bits.
The compression ratio, (S/D), is 8.864883587517724.


For a quantization level n = 1

The original image cost, (S), is 1638000.0 bits.
The Y values cost is 90048.0 bits.
The Cb values cost is 19215.0 bits.
The Cr values cost is 14483.0 bits.
The total compressed image cost, (D), is 123746.0 bits.
The compression ratio, (S/D), is 13.236791492250255.


For a quantization level n = 2

The original image cost, (S), is 1638000.0 bits.
The Y values cost is 60932.0 bits.
The Cb values cost is 12480.0 bits.
The Cr values cost is 9960.0 bits.
The total compressed image cost, (D), is 83372.0 bits.
The compression ratio, (S/D), is 19.646883845895506.


For a quantization level n = 3

The original image cost, (S), is 1638000.0 bits.
The Y values cost is 41760.0 bits.
The Cb values cost is 9206.0 bits.
The Cr values cost is 7028.0 bits.
The total compressed image cost, (D), is 57994.0 bits.
The compression ratio, (S/D), is 28.244301134600132.


For a quantization level n = 4
The original image cost, (S), is 1638000.0 bits.
The Y values cost is 28128.0 bits.
The Cb values cost is 6372.0 bits.
The Cr values cost is 4752.0 bits.
The total compressed image cost, (D), is 39252.0 bits.
The compression ratio, (S/D), is 41.73035768878019.



For a quantization level n = 5

The original image cost, (S), is 1638000.0 bits.
The Y values cost is 20090.0 bits.
The Cb values cost is 4212.0 bits.
The Cr values cost is 3546.0 bits.
The total compressed image cost, (D), is 27848.0 bits.
The compression ratio, (S/D), is 58.81930479747199.

 

Dune.ppm

For a quantization level n = 0
The compression ratio, (S/D), is 10.640435038620069.


For a quantization level n = 1
The compression ratio, (S/D), is 17.213579788612535.



For a quantization level n = 2
The compression ratio, (S/D), is 26.61987391954247.



For a quantization level n = 3
The compression ratio, (S/D), is 38.216085090501956.

For a quantization level n = 4
The compression ratio, (S/D), is 52.463495858594484.


For a quantization level n = 5
The original image cost, (S), is 2457600.0 bits.
The Y values cost is 25320.0 bits.
The Cb values cost is 5016.0 bits.
The Cr values cost is 4917.0 bits.
The total compressed image cost, (D), is 35253.0 bits.
The compression ratio, (S/D), is 69.71321589651944.

Last edited by cbort at 01:31 May 13, 2011.
ashasabeer
Posts: 55
Posted 17:07 May 13, 2011 |

Here is my output..But it looks funny compare to others.

Ducky.ppm

N: 0
Number of bits for Y: 26880
Number of bits for Cr: 6336
Number of bits for Cb: 6336
Compression Ratio: 41.41383495145631

 

N: 1
Number of bits for Y: 24640
Number of bits for Cr: 5760
Number of bits for Cb: 5760
Compression Ratio: 45.29867256637168

N: 2
Number of bits for Y: 22400
Number of bits for Cr: 5184
Number of bits for Cb: 5184
Compression Ratio: 49.98779296875
 

N: 3
Number of bits for Y: 20160
Number of bits for Cr: 4608
Number of bits for Cb: 4608
Compression Ratio: 55.759803921568626

N: 4
Number of bits for Y: 17920
Number of bits for Cr: 4032
Number of bits for Cb: 4032
Compression Ratio: 63.03879310344828
 

N: 5
Number of bits for Y: 15680
Number of bits for Cr: 3456
Number of bits for Cb: 3456
Compression Ratio: 72.50354107648725
kknaur
Posts: 540
Posted 20:02 May 13, 2011 |

I  think there is something funny with the way way you are calculating the compression ratio.  I don't think the bits for Cr and Cb should be the same because the number of bits it takes to encode each 8x8 block will vary based on how many (code, value) pairs it takes to encode that one 8x8 block, and its more likely each 8x8 block will require a different amount of (code, value) pairs.  It's possible that the bits could come out the same but highly unlikely i think.   

 
 
ashasabeer wrote:

Here is my output..But it looks funny compare to others.

Ducky.ppm

N: 0
Number of bits for Y: 26880
Number of bits for Cr: 6336
Number of bits for Cb: 6336
Compression Ratio: 41.41383495145631

 

N: 1
Number of bits for Y: 24640
Number of bits for Cr: 5760
Number of bits for Cb: 5760
Compression Ratio: 45.29867256637168

N: 2
Number of bits for Y: 22400
Number of bits for Cr: 5184
Number of bits for Cb: 5184
Compression Ratio: 49.98779296875
 

N: 3
Number of bits for Y: 20160
Number of bits for Cr: 4608
Number of bits for Cb: 4608
Compression Ratio: 55.759803921568626

N: 4
Number of bits for Y: 17920
Number of bits for Cr: 4032
Number of bits for Cb: 4032
Compression Ratio: 63.03879310344828
 

N: 5
Number of bits for Y: 15680
Number of bits for Cr: 3456
Number of bits for Cb: 3456
Compression Ratio: 72.50354107648725
Last edited by kknaur at 20:04 May 13, 2011.
ashasabeer
Posts: 55
Posted 23:22 May 13, 2011 |

Thanks for the help..

i fixed some of my code .here is my new output

 

N: 0
Number of bits for Y: 141956
Number of bits for Cr: 21488
Number of bits for Cb: 29456
Compression Ratio: 8.491446345256609

N: 1
Number of bits for Y: 101894
Number of bits for Cr: 14769
Number of bits for Cb: 19395
Compression Ratio: 12.038983374737244
N: 2
Number of bits for Y: 72681
Number of bits for Cr: 10164
Number of bits for Cb: 12816
Compression Ratio: 17.122965471822372
N: 3
Number of bits for Y: 51444
Number of bits for Cr: 7193
Number of bits for Cb: 9514
Compression Ratio: 24.034863758418805

N: 4
Number of bits for Y: 36092
Number of bits for Cr: 4842
Number of bits for Cb: 6562
Compression Ratio: 34.48711470439616
 
N: 5
Number of bits for Y: 24600
Number of bits for Cr: 3537
Number of bits for Cb: 4311
Compression Ratio: 50.48076923076923
eykang
Posts: 95
Posted 21:15 May 16, 2011 |

The zigzag order is wrong. The first AC should be -7, not -1.

--Kang

 
 
cbort wrote:

 

for waterfall QuantizedYs[9][9]:

  -72    -7    -2    -1     0     0     0     0
   -1     8    -8    -1     0     0     0     0
   -8    12     1    -2    -1    -1     0     0
   -4     1     2     0     0     0     0     0
    1     1     0     1     0     0     0     0
    0     0     1     0     0     0     0     0
    0     0     0     0     0     0     0     0
    0     0     0     0     0     0     0     0

Encoded values
(Value, runlength)
NOTE #1. is the DC...

  1. (-72.0, 0.0)
  2. (-1.0, 1.0)
  3. (-7.0, 1.0)
  4. (-2.0, 1.0)
  5. (8.0, 1.0)
  6. (-8.0, 1.0)
  7. (-4.0, 1.0)
  8. (12.0, 1.0)
  9. (-8.0, 1.0)
  10. (-1.0, 1.0)
  11. (0.0, 1.0)

Encoded values continued

 13.   (-1.0, 1.0)
14.   (1.0, 3.0)
15.   (0.0, 1.0)
16.   (1.0, 1.0)
17.   (2.0, 1.0)
18.   (-2.0, 1.0)
19.   (0.0, 4.0)
20.   (-1.0, 1.0)
21.   (0.0, 6.0)
22.   (1.0, 2.0)
23.   (0.0, 1.0)
24.   (-1.0, 1.0)
25.   (0.0, 30.0)

 



 

My answer was incorrect before for all cases that were not 1 solid color. My new answer however is not equal to yours and I traced my quantized block and what it encoded, so I am fairly certain it is right now... Try doing the same thing and see if your trace goes zigzag like it is supposed to

 

 

Last edited by eykang at 21:16 May 16, 2011.