2
我想要做的是對圖像量化DCT係數的直方圖,以檢測雙量化效應。當我使用hist(x)時,它會將其分類到10s,如果我將它更改爲hist(x,20)或30,它並不真正顯示DQ效果。那麼有沒有更好的方法呢? 這裏是代碼:MATLAB的如何做dct係數的直方圖顯示雙量化效果?
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