2
$\begingroup$

The picture below is drawn by the DCT coefficients after making DCT to an image :

the DCT coefficients distribution if an image

I want to get an image like the picture above. Here are some problems:

  1. Should I do the DCT to the whole image instead of using the block DCT? And what MATLAB function should I use?
  2. How to deal with the coefficients? Make it in the range of $[0, 255]$? Or make the coefficients matrix to be a Binary Image?

I would really appreciate if someone can help me!

$\endgroup$

1 Answer 1

2
$\begingroup$

The general shape of this image can (probably) be obtained with Matlab function DCT2 applied on the whole image (problem 1). I suspect this image comes from the absolute of the actual DCT matrix which generally has positive and negative values (problem 2). The absolute value was probably modified by a non-linear mapping, such as a logarithm or a power. The reason is you almost mostly black values on the bottom-right, probably zeroes at high frequencies. Would you have positive and negative values, this area could appear in mid-gray colors.

The PNG file has 251 colors, so the absolute DCT matrix with real values was somehow rounded to 8 bits, possibly scaled, and not binarized.

On your question: How to deal with the coefficients? you should tell us what you would like to do apart from displaying a grayscale absolute 2D DCT image. You can compute energy concentration in the DCT domain, or identify the two bright lines as two main orientations with high gradients on the original image.

The following code produces a similar image, depicted below.

parBoxCox = 0.15;
data = imread('gantrycrane.png');
dataTrans = (1+(abs(dct2(rgb2gray(data))))).^parBoxCox;
dataTrans = floor(dataTrans*255/max(dataTrans(:)));
imagesc(dataTrans);colormap gray

DCT image

$\endgroup$
5
  • $\begingroup$ To see an image like above image, you must calculate log10 of you DCT values and show them. The dynamic range of DCT coefs is too high to be fitted in small range of 0 to 255. Some code might be useful here, I=imread('Your Image.Image'); DCT=dct2(I); imshow(log10(DCT),[]); $\endgroup$
    – MimSaad
    Aug 13, 2016 at 17:35
  • $\begingroup$ No, it is better to be in comments as I put, however your answer would improve I feel, if you mention dynamic range reduction through applying a logarithmic function. $\endgroup$
    – MimSaad
    Aug 13, 2016 at 18:11
  • $\begingroup$ you are absolutely right. of course we do not have such thing as logarithm DCT transform, We only take logarithm of the DCT coefficients for better visualization. But the above image is surely, is image of logarithm of DCT coefficients not the DCT itself. Give it a try in Matlab and you'll see. $\endgroup$
    – MimSaad
    Aug 13, 2016 at 18:42
  • $\begingroup$ @Mimsaad Good idea, done $\endgroup$ Aug 13, 2016 at 20:44
  • $\begingroup$ Normalization also works, well done! $\endgroup$
    – MimSaad
    Aug 14, 2016 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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