Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

# JFIF Image class - Java

### #16 bdlt Posted 22 August 2007 - 12:07 PM

bdlt

Member

• Member
• 875 posts
give me some time to do some research on your 8x8 DCT question.

I will try to find a reference that explains it clearly.

I'm not sure about the 8 block reference.

dct processes 64 pixels in an 8 by 8 block
• 0

### #17 bdlt Posted 22 August 2007 - 12:36 PM

bdlt

Member

• Member
• 875 posts
most of the references explain the encoding process.

DCT is Discrete Cosine Transfer

IDCT is Inverse Discrete Cosine Transfer

you want to code for IDCT( we want to undo what was done during encoding)

................................................................................

the decoding process is done in reverse order and the process 'reverses' the encoding process.

example - if a value is multiplied during the encoding process, it is divided during the decoding process

I'm hoping to find a reference that provides decoding formulas and one that is also easy to follow.
• 0

### #18 staticVoid Posted 22 August 2007 - 12:49 PM

staticVoid

Member

• Topic Starter
• Member
• 94 posts
what I'm confused about is the output from a step should be inputted into the next step.

say for example I was encoding a to a jpg image>

I would have the RGB values of each pixel then I would convert them to YCbCr then change them to signed values then...

DCT gives the equation:

c(u,v) 7 7 2*x+1 2*y+1

F(u,v) = --------- * sum sum f(x,y) * cos (------- *u*PI)* cos (------ *v*PI)

4 x=0 y=0 16 16

what are the values u, v, x, y, sum and F - what is it I am trying to find in the first place

I take it the (--------) are just dividing lines for the objects at the top and bottom

Im trying to understand how the jpg is compressed in order for me to decompress it.
• 0

### #19 bdlt Posted 22 August 2007 - 01:01 PM

bdlt

Member

• Member
• 875 posts
input and output are processed in 8x8 blocks

for encoding:

a block of 8x8 pixels values(input) are processed at step 1.
the output is an 8x8 block which becomes the input for step 2.

this is repeated for each step

..........................................................................

we are always handling a block of 8x8 values

8x8 goes into a process. 8x8 comes out of a process(this is now the input for the next process)

............................................................................

we apply a formula to each of the 64 values and save those 64 values for the next step

..........................................................................

I will try to find a good example
• 0

### #20 bdlt Posted 22 August 2007 - 01:25 PM

bdlt

Member

• Member
• 875 posts

http://www.mathworks...objectType=file

cosines and alpha are defined in the file
I - input
O - output

note - I has 64 values, O has 64 values

warning - your loop variables will start at 0, not 1

still looking for a good reference ...
• 0

### #21 staticVoid Posted 22 August 2007 - 01:36 PM

staticVoid

Member

• Topic Starter
• Member
• 94 posts
I think I understand the 8x8 block - does it mean that the first 64 pixels in the actuall image data account for the 8x8 block and then the next 64 pixels account for the next 8x8 block and so on from left to right and top to bottom?>

1 2 3 4 5 6 7 8 | 65 66 67 68 69 70 71 72
9 10 11 12 13 14 15 16 | 73 74 75 76 77 78 79 80
17 18 19 20 21 22 23 24 | 81 82 83 84 85 86 87 88
15 26 27 28 29 30 31 32 | 89 90 91 92 93 94 95 96
33 34 35 36 37 38 39 40 | 97 98 99 100 101 102 103 104
41 42 43 44 45 46 47 48 | 105 106 107 108 109 110 111 112
49 50 51 52 53 54 55 56 | 113 114 115 116 117 118 119 120
57 58 59 60 61 62 63 64 | 121 122 123 124 125 126 127 128

Edited by staticVoid, 22 August 2007 - 01:38 PM.

• 0

### #22 bdlt Posted 22 August 2007 - 02:04 PM

bdlt

Member

• Member
• 875 posts
once the 8x8 block is established it is as you describe.

but ...

your raw pixel data may be sequential

let's say we have a 1MB image(1024x1024 pixels)

the raw pixel data may be more like this:
1 2 3 4 5 6 7 8 .... 1023 1024
1025 1026 .... 2047 2048
2049 2050 .... 3071 3072
...
6145 6146 .... 7167 7168
7169 7170 .... 8191 8192

so the first 8x8 block would be filled with these pixel indices
1 2 3 4 5 6 7 8
1025 1026 1027 1028 1029 1030 1031 1032
2049 2050 2051 2052 2053 2054 2055 2056
3073
4097
5121
6145
7169 7170 7171 7172 7173 7174 7175 7176

I hope this makes some sense
................................................................................
...............

you will be adjusting indices(as above) often in the compression/decompression operation.

you might consider storing the input/output values in arrays

....................................................................

FYI - I am available for another hour today
• 0

### #23 staticVoid Posted 22 August 2007 - 02:23 PM

staticVoid

Member

• Topic Starter
• Member
• 94 posts
I thought the pixel data should have three components - YCbCr or RGB or is that the pixel data when it has been passed through the DCT equation?
• 0

### #24 bdlt Posted 22 August 2007 - 02:27 PM

bdlt

Member

• Member
• 875 posts
that is correct - there will be 3 values for each pixel

it's possible that one of the steps will reduce it to a single value ... more research is required

Edited by bdlt, 22 August 2007 - 02:32 PM.

• 0

### #25 staticVoid Posted 22 August 2007 - 02:34 PM

staticVoid

Member

• Topic Starter
• Member
• 94 posts
So , In the DCT/IDCT equations what values do I replace Y , Cb and Cr with?
• 0

### #26 bdlt Posted 22 August 2007 - 02:49 PM

bdlt

Member

• Member
• 875 posts
this will make more sense if the flow of the compression/decompression is known.

I will leave this research to you. maybe you already have a reference that describes the steps required for compression or decompression

it will look something like this

compression
step 1 output sent to step 2 process
step 2 output sent to step 3 process
...
step 7 output sent to step 8 process
eventually you create a jpeg file

decompression:
parse jpeg file
do the steps in reverse order and 'reverse' the compression process
eventually you get raw pixel data(3 values for each pixel)

................................................................................

let's say IDCT is step 5
the input for IDCT is the output of step 6 during compression(only for decompression the process is 'reversed')

................................................................................

so far I seem to find only sites that list 3 or 4 steps - maybe you will have better luck

• 0

### #27 staticVoid Posted 22 August 2007 - 02:54 PM

staticVoid

Member

• Topic Starter
• Member
• 94 posts
I'm referring to http://www.opennet.r...ormats/jpeg.txt for all the steps.
• 0

### #28 bdlt Posted 22 August 2007 - 03:21 PM

bdlt

Member

• Member
• 875 posts
this reference looks like it has all of the steps

for compression
step 4 is DCT
step 5 is zig zag

therefore for decompression
the input for IDCT(not DCT) is the output of zig zag

does this make sense?
................................................................................
....

I can't tell you at this point whether we are dealing with 3 pixel values or whether it has been reduced to one value ... more reading is required ... it's probably in this reference somewhere
• 0

### #29 staticVoid Posted 23 August 2007 - 01:02 AM

staticVoid

Member

• Topic Starter
• Member
• 94 posts
Yes, It makes sense - I have to rearrange the order of the zig-zag so that its left to right / top to bottom in step 5 then input each value in the new 8x8 block into the IDCT equation?

but to retract each value (Y, Cb and Cr) do I have to rearrange the equation for each component(YCbCr) and ifso what values in the equation do I replace with Y , Cb, Cr?

It says the equation for IDCT is:

for q = 1 : 8
s = s + (alpha(p,q) * double(I(p,q)) * cosines(p,m) * cosines(q,n));

but the values and functions I'm not sure about are alpha() , double() , I , p , m and n;

although I take it p , m and n are where you replace Y , Cb and Cr? but which goes with which?

Edited by staticVoid, 23 August 2007 - 06:18 AM.

• 0

### #30 staticVoid Posted 23 August 2007 - 11:18 AM

staticVoid

Member

• Topic Starter
• Member
• 94 posts
I found a good reference - http://en.wikipedia.org/wiki/JPEG
• 0

### Similar Topics

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users