I = imread('peppers.png'); bs = 8 fun = @dct2; J = blkproc(I,[bs bs],fun); figure(1); subplot(1,2,1); imshow(I, []) subplot(1,2,2); imshow(J, []) q = 20; Jc= round(J/q)*q; save 'peppers_orig.mat' I save 'peppers_J.mat' J save 'peppers_Jc.mat' Jc fun = @idct2; R = blkproc(J,[bs bs],fun); Rc = blkproc(Jc,[bs bs],fun); figure(2) subplot(1,2,1);imshow(R, []) subplot(1,2,2);imshow(Rc, []) x = linspace( min(J(:)), max(J(:)), 1000); h = hist(J(:), x); hc = hist(Jc(:), x); figure(3) plot(x,log(h+1),'r', x,log(hc+1),'b') figure(4); imshow(Jc-J, []) max(abs(Jc(:)-J(:)))