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)
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

Answers (2)

Image Analyst
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
Osman
Osman on 9 Nov 2015
this is the question im trying to figure out ;
Write a script to divide up an entire image (assume grayscale) 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). [HINT]: you can use the blockproc() function in matlab to simplify this process

Sign in to comment.


TUMMALA ANIL CHOWDARY
TUMMALA ANIL CHOWDARY on 27 Jan 2021
imshow(T);
This will give you DCT Coefficients

Community Treasure Hunt

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

Start Hunting!