资源简介
信息论的课程设计,算术编码,输入信源符号和相应的概率,输入要编码的序列,可以得出编码结果,顺便直接译码。
代码片段和文件信息
#include
#include
#include
#include
#include
char code[100];
double ps=1;
double d=0;
double HighLowlowhigh;
int n;
int l;
char code_1[100];
char code_2[100];
double k;
struct MY
{
char my;
float p;
}myfh[5];
/*double verse()
{
double m;
double tem;
while(code_1[i]!=‘\0‘)
{
tem=code_1[i]-48;
for(j=0;j tem=tem*0.5;
m=m+tem;
}
return m;
}*/
float FS(int i)
{
float fs=0;
if(i==0)fs=0;
for(int j=0;j fs+=myfh[j].p;
return fs;
}
void decode(double k)
{
// k=verse();
double D;
int j=0;
int i=1;
while(1)
{
if (k<=FS(j)+myfh[j].p&&k>=FS(j))break;
j++;
}
Low=FS(j);
High=Low+myfh[j].p;
d=myfh[j].p;
code_2[0]=myfh[j].my;
j=0;
while (k!=Low&&j {
while(j {
high=Low+d*(FS(j)+myfh[j].p);
low=Low+d*FS(j);
D=d*myfh[j].p;
j++;
if(k=low)break;
}
code_2[i]=myfh[j-1].my;
High=high;
Low=low;
d=D;
j=0;
i++;
}
}
void reverse(double m int l)
{
//转小数部分
int temi=0;
while(m&&l)
{
tem=int(m*2);
code_1[i]=tem+48;
m = m*2 - int(m*2);
l--;
i++;
}
code_1[i]=‘\0‘;
}
void PS()
{
int i=0j=0;
while(code[i]!=0)
{
for(j=0;j {
if(code[i]==myfh[j].my)
ps*=myfh[j].p;
}
i++;
}
}
void length()
{
PS();
l=ceil(log10(1/ps)/log10(2));
}
void encode()
{
int i=1;int j;
for (j=0;j {
if(code[0]==myfh[j].my)
{
Low=FS(j);
High=Low+myfh[j].p;
d=myfh[j].p;
}
}
while(code[i]!=10)
{
for (j=0;j {
if(code[i]==myfh[j].my)
{
high=Low+d*(FS(j)+myfh[j].p);
low=Low+d*FS(j);
High=high;
Low=low;
d=d*myfh[j].p;
}
}
i++;
}
}
void main()
{
int i;
printf(“请输入码元符号的个数:\n“);
scanf(“%d“&n);
for(i=0;i {
printf(“请输入码元符号:\n“);
getchar();
scanf(“%c“&myfh[i].my);
printf(“请输入码元符号的概率:\n“);
scanf(“%f“&myfh[i].p);
}
printf(“请输入要编码的序列:\n“);
scanf(“%s“code);
encode();
printf(“the range is (%.8f %.8f) \n“LowHigh);
length();
reverse(Lowl);
printf(“%s“code_1);
decode(Low);
printf(“the decoded result is :\n“);
printf(“%s“code_2);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 34304 2006-12-25 22:31 算术编码\信息论与编码实验三.doc
文件 2411 2008-12-17 02:45 算术编码\算术编码.cpp
目录 0 2008-12-19 19:06 算术编码
----------- --------- ---------- ----- ----
36715 3
- 上一篇:人脸识别方法的设计与实现论文答辩ppt
- 下一篇:stm32内部结构图
相关资源
- 编程实现算术编码 输入任意字串 输出
- 游程编码(信息论课程设计)
- 信息论课程设计费诺编码与译码
- 信息论课后答案
- 费诺编码与译码
- 信息论与编码详细课后答案
- 信息论与编码_陈运主编_无水印完整版
- lz编码 信息论 编码理论
- 信息论基础理论与应用 课后题答案
- 信息论 香农,费诺,霍夫曼编码
- 信息论基础 第二版 答案
- arithmeticcoding.c
- 信息论与编码第五章课后习题答案
- MQ算术编码器原理及实现
- 算术编码包括编码解码
- 中国海洋大学信息论基础期末考试题
- 唯一可译码-信息论作业
- 《信息论》(电子科大)复习资料
- 信息论论文自己整理的哦
- 应用信息论基础试题清华大学
- 朱雪龙《应用信息论基础》习题答案
- 游程编码、算术编码、哈夫曼编码、
- 信息理论与编码实验报告
- 信息论与编码第2版的参考答案
- 信息论基础第二版答案Thomas M. Cover
- 信息论基础习题和答案.pdf
- Information Theory Coding Theorems for Discret
- 信息论与编码
- 信息论基础习题解答
- 信息论与编码(陈运)习题答案
评论
共有 条评论