views:

84

answers:

1

hello i need to perform quantization to dct cofficents for an image, for a block size of 8*8 pixles in matlab. can you help me with the syntax, thank you.

+1  A: 

There is a built-in function in MATLAB for DCT.

You need the signal processing tool box. Type 'ver' (without quotes) in the MATLAB command to see if you have it.

The code:

image = image; % define your image

[m,n] = size(image); % get size of your image

imvector = reshape(image, m*n, 1); % reshape your image to a vector to compute DCT

imdct = dct(imvector); % compute DCT 

imagedct = reshape(imdct,m,n); \ reshape result back to original form of your image
hkf