How can I turn a grayscale image into a 8x8 block and then show the DCT coefficients in each block as an image?
4 views (last 30 days)
Show older comments
So basically, I have to divide up an entire image into 8x8 blocks, and perform the 2D DCT for each block, outputting the results into a new image such that the new image shows DCT coefficients for each corresponding image block.
So far this is what I have;
% code
I = imread('lenagray.jpg');
I = im2double(I);
T = dctmtx(8);
dct = @(block_struct) T * block_struct.data * T';
B = blockproc(I,[8 8],dct);
figure;
imagesc(B)
just need help with making a image of the DCT coefficients
0 Comments
Answers (2)
Image Analyst
on 8 Nov 2015
An adaptation of the example in the help for dctmtx() is:
grayImage = imread('lena.jpg');
grayImage = im2double(grayImage);
D = dctmtx(size(grayImage,1));
dct = D*grayImage*D';
imshow(dct)
4 Comments
Image Analyst
on 9 Nov 2015
Even the attached JPG image?
theImage = imread('lena.jpg');
size(theImage)
ans =
512 512
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!