-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjpegdeco.m
27 lines (26 loc) · 943 Bytes
/
jpegdeco.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function [decodedimage] = jpegdeco(encoded,dict,allindices,qtable,r,c)
%Inputs
% 1- encoded which is the jpeg encoded image
% 2- dict which is the huffman dictionary that was used for encoding (to
%be used in decoding)
% 3- allindices is going to be used to reverse the zigzag pattern (to be
% used in decoding)
% 4- qtable which is the table that was used to quantize the image
%Outputs
% 1- decoded image which is the after decoding
%decode the image using huffman decoding, then Runlength decoding
decoded=huffmandeco(encoded,dict);
decoded=DecodeRL(decoded);
L=length(decoded);
decodedimage=zeros(r,c);
%use allindices to assign the values of the linear array to their
%appropriate position in the 2d iamge array
j=1;
for i=1:L
decodedimage(allindices(j),allindices(j+1))=decoded(i);
j=j+2;
end
%dequantize the image and then perform IDCT
decodedimage=jpeg_dequantize(decodedimage,qtable);
decodedimage=myIDCT(decodedimage);
end