1
$\begingroup$

In digital image forensic, it is assumed that the histogram of DCT coefficients of the un-compressed natural image has the smooth histogram. However, the histogram of DCT coefficients of the compressed natural image has peaks and gap in it. One such problem is discussed in this work. see this image for a better understanding histogram plot of DCT coefficients.

I am using the following MATLAB code to plot the histogram of DCT coefficients of uncompressed and compressed images.

x_axis = -1000:0.01:1000;

img_1 = rgb2gray(imread('a.tif'));
img_2 = rgb2gray(imread('b.tif'));

subplot(2,2,1), imshow(img_1), title('Image');
subplot(2,2,2), imshow(img_2), title('Compressed Image');
subplot(2,2,3), plot(x_axis, histogram(dct2(double(img_1)))), title('Image');
subplot(2,2,4), plot(x_axis, histogram(dct2(double(img_2)))), title('Compressed Image');

but I am unable to get the results in the desired manner. see this figure below results that I am getting.

Can anyone please explain? what is the correct way of plotting the histogram of DCT coefficient of an image so that I may get the correct results?

$\endgroup$
  • 1
    $\begingroup$ Try with a more evenly bright input image. $\endgroup$ – Marcus Müller Aug 9 '18 at 12:57
  • $\begingroup$ Sir, I have tried this code for more than 20 images of all types, but I am still facing the same problem. $\endgroup$ – Mayank Tiwari Aug 10 '18 at 5:18
  • 1
    $\begingroup$ I just recommended that because your input image's histogram was extremely concentrated $\endgroup$ – Marcus Müller Aug 10 '18 at 6:47
  • $\begingroup$ Hope this will be helpful : y = dct(double(Img)) $\endgroup$ – violet li Jul 15 at 3:16
  • $\begingroup$ Looks like you have a very strong DC component that may mask the rest of the coefficients. Have you tried centerin it, i.e., subtracting the image's mean before the DCT2? You can also try to put the y-axis logarithmically, this will reveal the smaller coefficients more visibly. $\endgroup$ – Florian Jul 15 at 7:38
0
$\begingroup$

My guess is that the assertion

"the histogram of DCT coefficients of the un-compressed natural image has the smooth histogram ... However, the histogram of DCT coefficients of the compressed natural image has peaks and gap in it."

is valid when one uses a compression method that uses a DCT and quantizes (sufficiently) it coefficents. This might not happen for compression methods outside JPEG, that uses a DCT2. Moreover, JPEG applies DCT2 on $8\times 8$ blocks, and the DC coefficient overgoes a compression scheme different than that of the AC coefficients.

So I am not surprized that you don't observe the quantization when you apply the DCT on the whole image (I obtained the same results).

What could be more successful is to compare the DCT coefficient histograms (DC removed) on each of the $8\times 8$ blocks, raw and compressed, and then combining the coefficients of all the blocks. Here is a quick attempt, in Matlab.

Histograms of DCT coefficients

nBin = 512;
dctCoeffLimit = 80;

img_1 = double(rgb2gray(imread('lena.bmp')));
img_2 = double(rgb2gray(imread('lena.jpg')));

% Compute block DCT with mean removed 
funDCT2 = @(block_struct) dct2(block_struct.data-mean(mean((block_struct.data))));
img_1DCT= (blockproc(img_1,[8 8],funDCT2));
img_2DCT= (blockproc(img_2,[8 8],funDCT2));

% Set DC coefficients to NaN
img_1DCT(1:8:end,1:8:end) = nan;
img_2DCT(1:8:end,1:8:end) = nan;

% Convert 2D to 1D
img_1DCTflat = img_1DCT(:);
img_2DCTflat = img_2DCT(:);

% Remove DC (NaN) values
img_1DCTflat(isnan(img_1DCTflat)) = [];
img_2DCTflat(isnan(img_2DCTflat)) = [];

subplot(1,2,1)
histogram(img_1DCTflat,nBin);axis([-dctCoeffLimit dctCoeffLimit 0 Inf]);
subplot(1,2,2)
histogram(img_2DCTflat,nBin);axis([-dctCoeffLimit dctCoeffLimit 0 Inf]);
$\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.