how to choose the n' coefficients of DCT function applied on JPG image?

2 visualizaciones (últimos 30 días)
1) DCT 2) Quantization 3) Compression (zig-zag style like JPEGs).
Does the dct2 function perform all of these functions automatically so or just the first step?
Some context of what I am trying to do:
Extract features from eye images for pattern recognition and classification. any eye images are transformed using the DCT and usually the first 30 or 35 co-efficients taken as input vectors. I am trying to understand what people mean when they talk about the "first" n co-efficients. Is it simply the first 30 [i,j] values after the DCT step or the first 30 co-efficients after the compression step(zigzag)? if it after the zigzag step ? how to send the choosen coeffficients to the idct2 as they will be as a vector not as a matrix?
RGB1 = imread('process/3.jpg');
figure
imshow(RGB1);
JJ = dct2(RGB1);
figure
imshow(JJ);
imshow(log(abs(JJ)),[]), colormap(jet), colorbar
JJ(abs(JJ) < 8) = 0;
[M N]=size(JJ);
fun=zigzag2(JJ);
B=fun;
B(1:1) = 0;
in1=invzigzag(B,M,N);
K2 = idct2(in1);
figure
imshow(K2,[0,255]);

Respuesta aceptada

Walter Roberson
Walter Roberson el 18 de Sept. de 2016
Does the dct2 function perform all of these functions automatically so or just the first step?
Just the first step
Is it simply the first 30 [i,j] values after the DCT step or the first 30 co-efficients after the compression step(zigzag)? if it after the zigzag step ?
It is after the zigzag step. Also, the number of coefficients would be per block, rather than total over the entire picture.
  3 comentarios
Walter Roberson
Walter Roberson el 18 de Sept. de 2016
You always apply the DCT to 8 x 8 blocks, not to the image as a whole. 8 x 8 = 64 DCT coefficients would be the result. You would take the zig-zag pattern on those 8 x 8, getting out a vector of length 64 for the block. Then you would take the first N of those coefficients as the result of the transform for that block.
blockproc() is a convenient way of handling this, but it is not the only way.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by