Oleh :
1.2 Simulasi
Coding :
%===================================================
%Putu sintia susiani pande-1304405018
%===================================================
%Reading image
a=imread('sintia.jpg');
figure(1);
imshow(a),title('Original Image');
pause (0.1);
%Huffman Encodig
hcode = huffmanenco(newvec,dict);
%Huffman Decoding
dhsig1 = huffmandeco(hcode,dict);
for x = 1:m
for y = 1:n
back(x,y)=dhsig(vec_si);
arr_col = arr_col+1;
vec_si = vec_si + 1;
end
arr_row = arr_row+1;
end
count =
Columns 1 through 8
0 2 2 2 7 6 5 4
Columns 9 through 16
7 3 12 27 35 50 70 122
Columns 17 through 24
Columns 25 through 32
Columns 33 through 40
Columns 41 through 48
Columns 49 through 56
Columns 57 through 64
Columns 65 through 72
Columns 73 through 80
Columns 81 through 88
Columns 89 through 96
134 140 130 158 147 174 150 149
91 82 80 87 86 95 90 89
100 99 89 80 68 67 54 74
60 62 45 52 45 54 49 38
Columns 193 through 200
40 52 53 36 48 39 35 40
37 31 34 35 34 36 24 31
31 36 30 18 23 20 24 27
22 19 17 23 15 30 21 12
15 22 17 22 19 22 12 13
13 18 12 19 18 20 20 22
11 23 18 17 20 21 13 12
24 31 31 35 39 50 296 456
Tampilan Citra :
Mulai
Masukkan Citra
Menentukan Ukuran
Citra
Menentukan Nilai
Simbol
Menghitung Nilai
Simbol
Merekontruksi Citra
Menyimpan Hasil
Selesai
ALGORITMA ARITMATIKA
2.2 Simulasi
Coding :
%===================================================
%Putu sintia susiani pande-1304405018
%===================================================
clc;
clear all;
close all;
%Arithmatic Coding
prompt='Masukkan Huruf = ';
str=input(prompt,'s');
arith=str;
len=size(str);
le=len(2);
count=[];
disp('Arithmatic Encoding Started');
for i=1:le-1
count(i)=1;
for j=i+1:le
if str(i)==str(j)
str(j)=0;
count(i)=count(i)+1;
end
end
end
if(str(le)~=0)
count(le)=1;
end
j=1;
%------------Transmitter part--------------------
for i=1:le
if(str(i)~=0)
new(j)=str(i);
p(j)=count(i)/le;
if(j>1)
ar(j)=ar(j-1)+p(j);
else
ar(j)=p(j);
end
disp(['Probability for ',str(i),' is ',num2str(p(j))]);
j=j+1;
end
end
larith=size(new);
l=[];u=[];
l(1)=0;
u(1)=ar(1);
for i=2:le
for j=1:larith(2)
if(arith(i)==new(j))
l(i)=l(i-1)+(u(i-1)-l(i-1))*(ar(j)-p(j));
u(i)=l(i-1)+(u(i-1)-l(i-1))*ar(j);
end
end
end
tag=(l(i)+u(i))/2;
disp(['The tag is ',num2str(tag)]);
%----------------Reciever part--------------
disp('Arithmatic Decoding Started');
rec='a';
tagr=tag;
for i=1:le
for j=1:larith(2)
if(tagr<ar(j) && tagr>(ar(j)-p(j)))
rec(i)=new(j);
nm=j;
end
end
if(nm>1)
tagr=(tagr-ar(nm-1))/p(nm);
else
tagr=tagr/p(nm);
end
end
Mulai
Masukkan Huruf
Menampilkan
Hasil
Selesai
ALGORITMA LZW
3.2 Simulasi
Coding :
%===================================================
%Putu sintia susiani pande-1304405018
%===================================================
clc;
clear all;
close all;
fprintf('Output: ');
fprintf('%02x ', lzwOutputd);
fprintf('\n');
for ii = 257:length(lzwTabled.codes)
fprintf('Code: %04x, LastCode %04x+%02x Length %3d\n', ii,
lzwTabled.codes(ii).lastCode, lzwTabled.codes(ii).c,
lzwTabled.codes(ii).codeLength)
end;
Hasil Command Window :
Input: 2f 57 45 44 2f 57 45 2f 57 45 45 2f 57 45 42 2f 57 45 54
Output: 0030 0058 0046 0045 0101 0046 0105 0106 0102 0043 0105 0055
Input: 61 62 63 41 41 41 7a 41 41 41 41 61 41 41 41 41 41 64 41 41 41 41 41 65
66 41 41 41 41 41 41 41 41 41 41 41 41 41 41 61 63 64 63
Output: 0062 0063 0064 0042 0104 007b 0104 0104 0062 0107 0104 0065 010a
0042 0066 0067 010d 0111 0107 0062 0064 0065 0064
Input: 0062 0063 0064 0042 0104 007b 0104 0104 0062 0107 0104 0065 010a
0042 0066 0067 010d 0111 0107 0062 0064 0065 0064
Output: 61 62 63 41 41 41 7a 41 41 41 41 61 41 41 41 41 41 64 41 41 41 41 41 65
66 41 41 41 41 41 41 41 41 41 41 41 41 41 41 61 63 64 63
Mulai
Masukkan Simbol
Menampilkan
Hasil
Selesai