0
$\begingroup$

I have computed the discrete cosine transform (DCT) of an image in MATLAB. I got a matrix of discrete cosine transform coefficients in the workspace. How can I recover the original image from its discrete cosine transform coefficients in MATLAB?

$\endgroup$
  • $\begingroup$ Apparently you already have the knowledge of the DCT/IDCT function. Do you have a specific issue? Color image, integer calculations $\endgroup$ – Laurent Duval Feb 3 '17 at 7:12
0
$\begingroup$

If you used dct2 on an image, or on each image channel separately for color images, with the appropriate input format, then idct2 recover the original image (the transformation is invertible and orthogonal), up to rounding errors (similar discussion in Why is $\exp(\ln(x))−x\neq 0$ in floating point arithmetic?).

You can find for instance a demo below:

dataRGB = double(imread('autumn.tif'));
data = rgb2gray(dataRGB/255);
dataDct=  dct2(data);
dataDctIdct = idct2(dataDct);

subplot(2,2,1)
imagesc(data); 
xlabel('Original (grayscale)');
subplot(2,2,2)
imagesc(log(abs(dataDct))); 
xlabel('Original DCT');
subplot(2,2,3)
imagesc(dataDctIdct); 
xlabel('Original recovered');
subplot(2,2,4)
imagesc(data-dataDctIdct); 
xlabel('Difference'); 
colorbar
colormap gray
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.