3

what i want to do is a histogram for quantized DCT coefficient for an image, to detect Double Quantization effect. when i use hist(x) it will categorize it in to 10s and if i changed it to hist(x,20) or 30 it does not really show the DQ effect. so is there any better way for this?? here is the code: on matlab

im = jpeg_read('image');
% Pull image information - Lum, Cb, Cr
lum = im.coef_arrays{im.comp_info(1).component_id};
cb = im.coef_arrays{im.comp_info(2).component_id};
cr = im.coef_arrays{im.comp_info(3).component_id};
% Pull quantization arrays
lqtable = im.quant_tables{im.comp_info(1).quant_tbl_no};
cqtable = im.quant_tables{im.comp_info(2).quant_tbl_no};
% Quantize above two sets of information
qcof = quantize(lum,lqtable);
bqcof = quantize(cb,cqtable);
rqcof = quantize(cr,cqtable);
hist(qcof,30); %lum quantized dct coefficient histogram
4

1 回答 1

2

首先,不需要量化系数。其次,可以通过绘制某些频率的直方图来观察效果。您需要遍历块中的各个位置并寻找模式。绘制直方图的 FFT 会有所帮助。

这是matlab代码:

imJPG2 = jpeg_read('foto2.jpg');
lum = imJPG2.coef_arrays{imJPG2.comp_info(1).component_id};
for i = 1:8
     for j = 1:8
        r = lum( i:8:end, j:8:end );
        histogram(r(:), 'binmethod','integers');
        pause();
    end
end

更多细节和背景可以在这篇论文中找到:http ://www.sciencedirect.com/science/article/pii/S0031320309001198

于 2015-12-07T04:59:16.497 回答