how to choose the n' coefficients of DCT function applied on JPG image?
2 次查看(过去 30 天)
显示 更早的评论
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]);
0 个评论
采纳的回答
Walter Roberson
2016-9-18
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 个评论
Walter Roberson
2016-9-18
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!