简体   繁体   中英

DCT transform in MATLAB

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

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)

The Figure looks as follows: 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM