필터 지우기
필터 지우기

Arithmetic coding explanation?

조회 수: 8 (최근 30일)
Aseel H
Aseel H 2012년 3월 15일
댓글: Yusuf lamah 2020년 3월 26일
Can any one help me in text compression by arithmetic coding
I try using the built_in function "arithenco" but i can not understand this example in description :
%The example below performs arithmetic encoding and decoding, using a source whose alphabet has three symbols.
seq = repmat([3 3 1 3 3 3 3 3 2 3],1,50);
counts = [10 10 80];
code = arithenco(seq,counts);
dseq = arithdeco(code,counts,length(seq));
I need compress text file

답변 (8개)

Walter Roberson
Walter Roberson 2012년 5월 19일
unique() your input; the result is your "alphabet". histc() your input against the alphabet. The result is the "counts". Now, arithenco the input against the counts to get the "codes".
  댓글 수: 4
Walter Roberson
Walter Roberson 2020년 3월 14일
Arithmetic coding is more efficient than Huffman
Yusuf lamah
Yusuf lamah 2020년 3월 17일
ext ='yusuf lamah'
input=double(text);
[alphabet,~,seq]=unique(input)
counts = histc(input,alphabet);
code = arithenco(seq,counts);
dseq = arithdeco(code,counts,length(input));
'how i can return the original text using arithdeco function '

댓글을 달려면 로그인하십시오.


slama najla
slama najla 2012년 5월 20일
편집: Walter Roberson 2020년 3월 14일
moi problème est dans ce party. Je trouve la taille de l'image compressée est très supérieure image originale
Mettre le code
% Alog le 0101010 de ... de de Dans un Vecteur de 8 bits par l'élement de L2 = Erreur% length (CODEH);
LCDH = round (L2 / 8);
Si mod (L2, 8) <4
Si mod (L2, 8) ~ = 0
LCDH = LCDH +1;
nageoire
nageoire
LcdnH = (LCDH) * 8;
DIFLcdH = (LcdnH)-L2;
codnH = zeros (1, LcdnH);
k = 1; versez i = 1: L2; codnH (k) = CODEH (i);
k = k +1;
nageoire
Tcod8H = zeros (1, la LCDH);
k = 1;
versez i = 1: la LCDH
versez j = 00:07
Tcod8H (i) = (codnH (k + j)) * (2 ^ j) + Tcod8H (i);
nageoire;
k = k +8;
nageoire;
LTH = length (Tcod8H);
LXF = length (XfuH);
A = []; P = []; B = [];
k = 1, ii = 1; jj = 1;
versez i = 1: si LXF XfuH (i)> 255
temp = abais (XfuH (i));
P (ii) = i;
versez j = 1:2
A (k) = temp (j);
k = k +1;
nageoire;
ii = ii 1;
D'AUTRE
B (jj) = XfuH (i);
jj = jj +1;
nageoire;
nageoire;
l = longueur (A);
h01 = redimensionnement (LXF);
H03 =% redimensionnement (LT);
H02 = redimensionnement (l);
H04 redimensionnement% = (T);
% H05 = redimensionnement (LXfu);
Fichier = [ABP h01 H02 Tcod8H DIFLcdH taille taille1 taille2 taille3];
% Taux_de_compression = MX * NX / length (fichier);
Gain_de_compression% = 100 * (1-Taux_de_compression)
% Gain_de_compression = 100 * (1-1/Taux_de_compression);
f = fopen ('compressionnnnn irm avec prédiction.comp', 'w');
fwrite (f, Fichier, 'ubit8');
fclose (f);

Yusuf lamah
Yusuf lamah 2020년 3월 14일
how to use counts in the following function ARITHENCO(SEQ, COUNTS)?
  댓글 수: 16
Yusuf lamah
Yusuf lamah 2020년 3월 26일
thanks alot WalterRoberson
Yusuf lamah
Yusuf lamah 2020년 3월 26일
how i can use xlawrite funtion to save the results in specific sheet and specific table in the Excel

댓글을 달려면 로그인하십시오.


Yusuf lamah
Yusuf lamah 2020년 3월 22일
Hello,i get warning:This is an obsolete function and may be removed in the future in randint line,please use RANDI instead "z1=randint(1,1,z); how i can use RANDI in this line instead of randint
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 3월 22일
https://www.mathworks.com/matlabcentral/answers/375213-how-can-replace-randi-instead-randint

댓글을 달려면 로그인하십시오.


Yusuf lamah
Yusuf lamah 2020년 3월 22일
i get output of RSA encryption was " 9 9 9 9 9 .... " i need to use huffman to compress the encrypted data out = 9 9 9 9 The value for n_ary must be less than or equal to the number of distinct symbol. error in
symbol_probs=symbol_counts./nume1(text); H4=num2cell(unique_symbols); dict=huffmandict =accumarray(bin_number,1); the error in last line dict line
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 3월 22일
Please post your actual code for that section . Please make sure it is formatted. Click the > Code button to get a code region and paste the code there

댓글을 달려면 로그인하십시오.


Yusuf lamah
Yusuf lamah 2020년 3월 23일
input=double(text);
counts=max(1,accumarray(input(:),1));
Acomp = arithenco(input,counts);
%%%%%%%%%%%%%
[unique_symbols, ~, bin_number] = unique(text(:));
symbol_counts = accumarray(bin_number, 1);
symbol_probs = symbol_counts ./ numel(text);
H4=num2cell(unique_symbols);
dict= huffmandict(H4,symbol_probs);
comp = huffmanenco(text,dict);
%%%%%%%%%%%%%
Both codes are working arithmetic and huffman but the big problem is the compression ratio in the huffman better than Arithmetic ,theoretical and practical the Arithmetic better than huffman
  댓글 수: 3
Yusuf lamah
Yusuf lamah 2020년 3월 23일
in the decode they were ok both of them return the original message but my quation why the ratio in huffman better than arithmetic sure there is something not correct on the code
Walter Roberson
Walter Roberson 2020년 3월 23일
You are permitting Huffman to encode from a set of symbols that includes only the characters used in the message. That set of characters is stored inside the Huffman dictionary and you are permitting the Huffman decoding to access that dictionary to do the decoding, so it can return the original characters.
Arithmetic encoding does not build a dictionary. It expects symbol numbers (not symbols) as the input, and relies on knowing the counts, and you are happy to pass in the counts to the decoding, but for some reason that I do not understand, you refuse to permit the decoding to use the information that would permit it to convert back from symbol numbers to symbols. Because of your refusal, it was necessary to make the symbol numbers the same as the symbols, which forces the encoding to emit a sequence about twice as large as it could be. If you would permit the alphabet variable to be used in the decoding then arithmetic encoding would be more efficient.

댓글을 달려면 로그인하십시오.


Yusuf lamah
Yusuf lamah 2020년 3월 25일
how i can can display many figure and there histogram in one graph for easy comparison

Yusuf lamah
Yusuf lamah 2020년 3월 26일
thank you very much Walter Roberson

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by