Distorted image after DCT compression

1 visualizzazione (ultimi 30 giorni)
Siyomnqoba
Siyomnqoba il 19 Ott 2015
Modificato: Siyomnqoba il 19 Ott 2015
After the image goes through the compression scheme (which does not include an entropy encoder) I get the following blurred image:
I think it has something to do with the way my code inserts an end of block (eob) symbol.
eob = 500;
r = zeros(numel(y) + size(y,2),1);
count = 0;
for j = 1:xb
i = find(max(y(:,j)));
if isempty(i)
i = 0;
end
p = count + 1;
q = p + i;
r(p:q) = [y(1:i,j);eob];
count = count + i + 1;
end
r((count + 1):end) = [];
What this code does is that,after the each 8x8 block of coefficients has gone through the DCT and quantization stages it was converted to a column and then a end of block symbol is inserted after 64 entries to indicate that we've reached the end of each block.
the following block of code, which i suspect is what's causing the problem, comes before the blocks go through the de-quantization and inverse DCT stages.
if true
% code
end
eob = 500;
z = zeros(64,xb);
k = 1;
for j = 1:xb
for i = 1:64
if k <8192
if x(k) == eob
k = k+1;
break;
else
z(i,j) = x(k);
k = k+1;
end
end
end
end
z = z(rev,:);
x = col2im(z, [8 8], [xm xn], 'distinct');
fun = @(block_struct) (block_struct.data .* m);
y = blockproc(x, [8,8], fun);
t = Cintra(dctmtx(8));
dct = @(block_struct) t' * block_struct.data * t ;
y = blockproc(y, [8,8], dct);
x = uint8(double(y) + 128);
It basically takes the long stream of coefficients removes the end of block symbols,rearrange the stream into 64 columns and then reverses the the zig-zag order done previously.Is there anything fundamentally wrong in the code above that I am currently missing? Please note that the code is designed for images that 512x512 pixels
It basically takes the long stream of coefficients removes the end of block symbols,rearrange the stream into 64 columns and then reverses the the zig-zag order done previously.Is there anything fundamentally wrong in the code above that I am currently missing? Please note that the code is designed for images that 512x512 pixels

Risposte (0)

Categorie

Scopri di più su Denoising and Compression in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by