DCT of an 8x8 matrix?

  • Follow


I'm trying to apply the DCT as described in [1], but it isn't working 
well.* Please take a look at my Maple worksheet in [2] (it is an HTML 
export). I would greatly appreciate a pointer as to what I could be 
doing wrong. As far as I can tell I am implementing the FDCT correctly.


Thank you,
James Sumners

[1] -- http://www.ijg.org/files/wallace.ps.gz
[2] -- http://student.claytonstate.net/~jsumners/DCT/index.html

* Actually, I'm not shifting the unsigned integers to signed. But I 
still shouldn't be getting the result I am getting I don't believe.

0
Reply James 4/27/2008 7:09:02 PM

James Sumners wrote:
> I'm trying to apply the DCT as described in [1], but it isn't working 
> well.* Please take a look at my Maple worksheet in [2] (it is an HTML 
> export). I would greatly appreciate a pointer as to what I could be 
> doing wrong. As far as I can tell I am implementing the FDCT correctly.

You need to make your term you're summing in the definition of the DCT 
of course dependent on x and y. Otherwise, you of course only get the 
constant term. That is, there should be an

A[x,y]

somewhere in your formula.

Hints:

a) This is a maple problem, and off-topic here.
b) I'm pretty sure maple offers a package containing the DCT readily 
implemented. It's usually not a good idea to re-invent the wheel. 
Specifically, the maple implementation might be faster and more general 
than yours.

So long,
	Thomas
0
Reply Thomas 4/27/2008 8:40:01 PM


On 2008-04-27 16:40:01 -0400, Thomas Richter <thor@math.tu-berlin.de> said:

> James Sumners wrote:
>> I'm trying to apply the DCT as described in [1], but it isn't working 
>> well.* Please take a look at my Maple worksheet in [2] (it is an HTML 
>> export). I would greatly appreciate a pointer as to what I could be 
>> doing wrong. As far as I can tell I am implementing the FDCT correctly.
> 
> You need to make your term you're summing in the definition of the DCT 
> of course dependent on x and y. Otherwise, you of course only get the 
> constant term. That is, there should be an
> 
> A[x,y]
> 
> somewhere in your formula.
> 
> Hints:
> 
> a) This is a maple problem, and off-topic here.
> b) I'm pretty sure maple offers a package containing the DCT readily 
> implemented. It's usually not a good idea to re-invent the wheel. 
> Specifically, the maple implementation might be faster and more general 
> than yours.
> 
> So long,
> 	Thomas

I asked here because I know there folks such as yourself who are quite 
familiar with this specific transform, and I am using it in the context 
of compressing an image with JPEG. So I felt it was at least 
tangentially on topic. I'm not asking for Maple help; I'm asking for 
help with the transform that is the basis of the JPEG compression 
scheme.

In regard to the A[x,y]. The 'z' in the inner sum is the 'f(x,y)' from 
Wallace's paper. I copied the double summation directly from that 
paper. As I understand it, if a grayscale image is represented by a 8x8 
matrix of integer color values, then f(x,y) is the integer at the [x,y] 
position of the matrix. Is this not correct?

If Maple offers a DCT package then it isn't included in my student 
installation. The closest thing I can find in the help file is a DFT.

0
Reply James 4/28/2008 12:25:55 AM

James Sumners wrote:
> On 2008-04-27 16:40:01 -0400, Thomas Richter <thor@math.tu-berlin.de> said:
> 
>> James Sumners wrote:
>>> I'm trying to apply the DCT as described in [1], but it isn't working 
>>> well.* Please take a look at my Maple worksheet in [2] (it is an HTML 
>>> export). I would greatly appreciate a pointer as to what I could be 
>>> doing wrong. As far as I can tell I am implementing the FDCT correctly.
>>
>> You need to make your term you're summing in the definition of the DCT 
>> of course dependent on x and y. Otherwise, you of course only get the 
>> constant term. That is, there should be an
>>
>> A[x,y]
>>
>> somewhere in your formula.
>>
>> Hints:
>>
>> a) This is a maple problem, and off-topic here.
>> b) I'm pretty sure maple offers a package containing the DCT readily 
>> implemented. It's usually not a good idea to re-invent the wheel. 
>> Specifically, the maple implementation might be faster and more 
>> general than yours.
>>
>> So long,
>>     Thomas
> 
> I asked here because I know there folks such as yourself who are quite 
> familiar with this specific transform, and I am using it in the context 
> of compressing an image with JPEG. So I felt it was at least 
> tangentially on topic. I'm not asking for Maple help; I'm asking for 
> help with the transform that is the basis of the JPEG compression scheme.

The formula is correct, the implementation is not.

> In regard to the A[x,y]. The 'z' in the inner sum is the 'f(x,y)' from 
> Wallace's paper. I copied the double summation directly from that paper. 

Nope. You wrote "z", the paper wrote "f(x,y)". Z might be a number, or a 
matrix, or anything else that can be multiplied or summed over, but it's 
at least *not* the *component* (x,y) of a matrix Z, as z, as you wrote 
it, does not depend on x and y, i.e. it's always the same number, or 
matrix, independent of x and y, which is kind of pointless. For that, 
you should write z[x,y]. Your code furthermore substitutes A[i,j] for z, 
which is different from A[x,y] since i and j do not depend on the 
summation indices x and y in the DCT transformation.

> As I understand it, if a grayscale image is represented by a 8x8 matrix 
> of integer color values, then f(x,y) is the integer at the [x,y] 
> position of the matrix. Is this not correct?

This is correct, but that's not reflected in your code. (-:

As said, it's *not* a math problem. It's a problem with "how to program 
maple".

> If Maple offers a DCT package then it isn't included in my student 
> installation. The closest thing I can find in the help file is a DFT.

Close enough. DCT and DFT are closely related. The DFT is likely a 
one-dimensional transformation, the DCT is more or less the real part of 
it, and you need to extend this to two dimensions by taking the tensor 
product of the transform with itself (or rather, less technically, you 
first transform in one direction, then into the second).

So long,
	Thomas
0
Reply Thomas 4/28/2008 11:02:22 AM

On 2008-04-28 07:02:22 -0400, Thomas Richter <thor@math.tu-berlin.de> said:

> James Sumners wrote:
>> On 2008-04-27 16:40:01 -0400, Thomas Richter <thor@math.tu-berlin.de> said:
>> 
>>> James Sumners wrote:
>>>> I'm trying to apply the DCT as described in [1], but it isn't working 
>>>> well.* Please take a look at my Maple worksheet in [2] (it is an HTML 
>>>> export). I would greatly appreciate a pointer as to what I could be 
>>>> doing wrong. As far as I can tell I am implementing the FDCT correctly.
>>> 
>>> You need to make your term you're summing in the definition of the DCT 
>>> of course dependent on x and y. Otherwise, you of course only get the 
>>> constant term. That is, there should be an
>>> 
>>> A[x,y]
>>> 
>>> somewhere in your formula.
>>> 
>>> Hints:
>>> 
>>> a) This is a maple problem, and off-topic here.
>>> b) I'm pretty sure maple offers a package containing the DCT readily 
>>> implemented. It's usually not a good idea to re-invent the wheel. 
>>> Specifically, the maple implementation might be faster and more general 
>>> than yours.
>>> 
>>> So long,
>>>     Thomas
>> 
>> I asked here because I know there folks such as yourself who are quite 
>> familiar with this specific transform, and I am using it in the context 
>> of compressing an image with JPEG. So I felt it was at least 
>> tangentially on topic. I'm not asking for Maple help; I'm asking for 
>> help with the transform that is the basis of the JPEG compression 
>> scheme.
> 
> The formula is correct, the implementation is not.
> 
>> In regard to the A[x,y]. The 'z' in the inner sum is the 'f(x,y)' from 
>> Wallace's paper. I copied the double summation directly from that paper.
> 
> Nope. You wrote "z", the paper wrote "f(x,y)". Z might be a number, or 
> a matrix, or anything else that can be multiplied or summed over, but 
> it's at least *not* the *component* (x,y) of a matrix Z, as z, as you 
> wrote it, does not depend on x and y, i.e. it's always the same number, 
> or matrix, independent of x and y, which is kind of pointless. For 
> that, you should write z[x,y]. Your code furthermore substitutes A[i,j] 
> for z, which is different from A[x,y] since i and j do not depend on 
> the summation indices x and y in the DCT transformation.

Oh, okay. I understand now. I've made the correction and am coming up 
with much better results. Thank you.

> 
>> As I understand it, if a grayscale image is represented by a 8x8 matrix 
>> of integer color values, then f(x,y) is the integer at the [x,y] 
>> position of the matrix. Is this not correct?
> 
> This is correct, but that's not reflected in your code. (-:
> 
> As said, it's *not* a math problem. It's a problem with "how to program maple".

Well, it kind was a math problem because I wasn't understanding the 
formula quite well enough. But I see your point.

Thank you again for your help.

0
Reply James 4/28/2008 3:28:19 PM

4 Replies
569 Views

(page loaded in 0.073 seconds)

Similiar Articles:













7/22/2012 2:34:42 PM


Reply: