Reputation: 1543
As you can see below, I have a 8*8 block of dct coefficients:
-15 -4 1 0 -1 0 0 0
-2 4 1 0 0 0 0 0
0 -1 0 0 0 0 0 0
0 -1 0 0 0 1 0 0
0 0 0 0 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
I want to get the real y coefficients, and after applying idct on this coefficients and adding 128, the result is like this:
119.993426127535 126.888835114344 127.977696208510 127.927114351222 127.622279963961 128.082250099117 127.919020270720 128
110.618267653250 126.957277975089 128.512507515489 127.935799524109 127.652389552519 128.091154805775 127.920065584190 128
136.573473239279 126.731190069890 128.405721622535 128.112408043987 127.702833109785 128.107866961225 127.922142717875 128
129.021166892476 127.268982345310 128.548746332762 128.260434777201 127.765160400749 128.130308763796 127.925224859437 128
124.152790434774 128.546202893775 127.700274478973 128.542888328457 127.836336292186 128.155643097180 127.929272223560 128
125.286184045103 128.030353688936 127.781062129255 128.439029577033 127.908068371778 128.180576157610 127.934232565512 128
125.224675818317 127.265893030837 127.509645458388 128.389987887226 127.958269682974 128.201709869820 127.940041855539 128
128.255190377282 127.039510378121 128.173941210798 128.024900885058 127.962852628740 128.215907305019 127.946625105377 128
but i was expecting to get this result:
88 72 72 56 38 75 109 89
69 88 86 69 73 82 76 65
86 114 83 48 69 77 67 81
90 106 80 49 62 81 86 95
55 64 86 88 81 103 112 83
51 49 77 87 75 112 138 106
56 64 69 63 75 113 139 134
29 73 77 75 111 126 114 119
I don't know what am I missing in this process.
Upvotes: 0
Views: 497
Reputation: 4941
I think you missed the quantization step.
The jpeg header must include a 8x8 quantization table. Simply multiply each coefficient of your 8x8 block by the corresponding coefficient from the quantization table before applying the inverse DCT, and you should get the right results!
Upvotes: 1