Reputation: 21
I want to find the DCT matrix of a picture. I tested the following code. But I can't see values of DCT matrix. Here is my code:
image = image;
[m,n] = size(image);
imvector = reshape(image, m*n, 1);
imdct = dct(imvector);
imagedct = reshape(imdct,m,n);
imshow(imagedct);
Upvotes: 2
Views: 900
Reputation: 570
1. You are trying to calculate the DCT of a 1D version of a 2D image using dct(imvector)
.
I think what you actually should do is calculating the 2D DCT of your 2D image using dct2(image)
.
2. The following MathWorks documentation pages are very helpful:
3. The following code calculates the DCT of a test image:
% Load sample image
image = imread('cameraman.tif');
% Normalise image
image = double(image)/255;
% Calculate DCT
imageDct = dct2(image);
% Display the image
figure
subplot(1,2,1)
imshow(image)
title('Original image','FontSize',24)
% Display the DCT
subplot(1,2,2)
imshow(imageDct)
title('DCT','FontSize',24)
Upvotes: 1