GG&JJ们能给小妹解释一下什么是lzw算法吗??

yhhgirl 2002-12-05 08:22:32
谢谢高手给我解释一下这个问题,最好能用C++写一些基本算法,有分的哟!!!
...全文
1372 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
fjian37 2002-12-26
  • 打赏
  • 举报
回复
mark
laughcry2002 2002-12-26
  • 打赏
  • 举报
回复
这个论坛中的小妹真多,而且都喜欢亮明自己不是男性...
yun_island 2002-12-17
  • 打赏
  • 举报
回复
这位大哥好厉害,写了这么多!我看得眼睛都痛!
zhoukun666 2002-12-17
  • 打赏
  • 举报
回复

while(table!=NULL)
{
if(strcmp(table->point,ctemp)==0)
{ return(j);}
else{
table=table->next;
j++;}
}
return(-1);
}/* End the inthetable()*/

void addtodictionary(char *p,struct cell *dic)
{
char *ctemp;struct cell *table,*dtemp;int i;
ctemp=malloc(sizeof(char));
strcpy(ctemp,p);table=dic;
for(i=1;i<=n;i++)
table=table->next;
dtemp=(struct cell *)malloc(sizeof(struct cell));
strcpy(dtemp->point,ctemp);
table->next=dtemp;dtemp->next=NULL;
n++;
}/*End the addtodictionary()*/

void expand(FILE *in,FILE *out,struct cell *dic)
{
FILE *ifp,*ofp;struct cell *table,*dtemp,*dtemp1;
int cw,pw,i,j,length,*w;
char *ctemp,*p,c[2];
w=malloc(sizeof(int));ctemp=malloc(sizeof(char));p=malloc(sizeof(char));
ifp=in;ofp=out;table=dic;
/*Chong Xin Ding Yi n*/
dtemp=table;
for(i=1;i<=31;i++)
dtemp=dtemp->next;
dtemp1=dtemp->next;
dtemp->next=NULL;
for(i=33;i<=n;i++)
{ dtemp=dtemp1->next;
free(dtemp1);
dtemp1=dtemp;} /*Chong Xin Ding YI\i Dictionary*/
j=fread(w,sizeof(int),1,ifp);
cw=*w;printf(" %d.",cw);
dtemp=table;
for(i=1;i<=cw;i++)
dtemp=dtemp->next;
strcpy(ctemp,dtemp->point);length=strlen(ctemp);
while(j!=0)
{
pw=cw;
j=fread(w,sizeof(int),1,ifp);
cw=*w;printf(" %d.",cw);
if((i=inthestringtable(cw,dic))!=-1)
{
dtemp1=table;
for(i=1;i<=cw;i++)
dtemp1=dtemp1->next;
strcpy(ctemp,dtemp1->point);
length=strlen(ctemp);
fwrite(ctemp,sizeof(char),length,ofp);
dtemp1=table;
for(i=1;i<=pw;i++)
dtemp1=dtemp1->next;
strcpy(p,dtemp1->point);
dtemp1=table;
for(i=1;i<=cw;i++)
dtemp1=dtemp1->next;
c[0]=*(dtemp1->point);c[1]='\0';
strcpy(ctemp,p);
strcat(ctemp,c);
addtodictionary(ctemp,table);
}
else
{
dtemp1=table;
for(i=1;i<=pw;i++)
dtemp1=dtemp1->next;
strcpy(p,dtemp1->point);
dtemp1=table;
for(i=1;i<=cw;i++)
dtemp1=dtemp1->next;
c[0]=*(dtemp1->point);c[1]='\0';
strcpy(ctemp,p);
strcat(ctemp,c);
length=strlen(ctemp);
fwrite(ctemp,sizeof(char),length,ofp);
addtodictionary(ctemp,table);
}
}
}
/*End The Expand()*/

int inthestringtable(int k,struct cell *dic)
{ struct cell *dtemp;int j=0;
dtemp=dic;
while(dtemp->next!=NULL)
{
if(j<k){ dtemp=dtemp->next;
j++;}
else if(j==k){return(j);}
}
if(j==k)
return(j);
else
return(-1);
}
五、程序的调试:
通过调试,在排除程序的所有语法,算法错误和所有的警告后,对程序进行初步尝试性运行,我先新建一文本文件c:\tc\zk.txt,其内容只由小写字母“a,b,c,……“和“,。;:“以及回车和换行符组成的“abacaba”,然后运行LZW.C:
<1> for Compress.<2> for Expand.<0> for Exit!
Please Input Your Choise:1
Please Input The Compressing File Name:d:\tc\as.txt
Please Input The Name for the Compressed File:d:\tc\123.txt
元文本文件zk.txt的文件大小是7字节,被压缩后的文件123.txt文件大小却是12字节,显然没有起到我们前面所预期的压缩功能,仔细思索其中的缘故,发现问题的所在是我们对这两个文件所进行的操作方式的差异------- 我们对zk.txt文件的读入方式用的是fgetc(ifp),也就是说是按照字符大小为单位的,而我们在对123.txt文件的写入操作用得却是fwrite(&j,sizeof(int),1,ofp);址操作是按照整数大小为单位来进行的,这样7个字节长的源文件内容“abacaba”所对应的是12个字节长的压缩码# 6#7#6#8#32#6,现暂时把这个问题放在一边,当务之急是要利用解压缩expand()来验证一下压缩compress的正确性:
<1> for Compress.<2> for Expand.<0> for Exit!
Please Input Your Choise:2
Please Input THe Expanding File Name:123.txt
Please INput the Name for THe Expanded File:zkk.txt
打开解压缩文件zkk.txt,其内容为“abacabaa”,很快发现前面的内容届亚的都么没问题,但是遗憾的是在正确内容的后面多了一个正确字符串的最后那个字符出来,没办法,现只能是再次利用F7来一步一步的检查,最后查得问题出在while(j!=0){}这个循环中间的fwrite(ctemp,sizeof(char),length,ofp);语句上,最后虽然得到这个问题对于少长一点的文件就没有影响的结论,但可惜的是一直没有想到解决这一问题的好办法.
最后所剩的调试问题是对压缩比例的检测:先创建一个大小为:51,421字节的zk.txt文本文件作为源文件,运行LZW.C对之进行压缩处理,得到一压缩后的文件123.txt,其大小为:40,346字节,当然在计算压缩比例前还得检查压缩的准确性-----运行LZW.C对123.txt进行解压操作,得到一文本文件Zkk.txt其大小为:51,421字节,经察看发现内容与源文件zk.txt的没有任何差别,这说明压缩过程和解压过程没有问题,同时也验证了前面所提到的解压后尾部多一字符对稍长的字符串没有影响的结论的正确性,但是计算得到的21.538%压缩比例不太理想,但这也由于我采用的读和写方式有一个单位成双倍的缘故,对一般没有任何规律的文本文件也只能大概是这个压缩比例了,若要是了解对文件读和写的位操作者一方法的话,那压缩比例马上就可以提高整整一倍,可惜的是一直没有找到这方面的资料.
jiangyu99 2002-12-16
  • 打赏
  • 举报
回复
mm你好有魅力阿
zhoukun666 2002-12-15
  • 打赏
  • 举报
回复
是判断字典的位置cw,后者是判断字符串ctemp*/
{temp1=table;
for(i=1;i<=cw;i++)
dtemp1=dtemp1->next;
strcpy(ctemp,dtemp1->point);length=strlen(ctemp);
fwrite(ctemp,sizeof(char),length,ofp); dtemp1=table;
for(i=1;i<=pw;i++)
dtemp1=dtemp1->next;
strcpy(p,dtemp1->point); dtemp1=table;
for(i=1;i<=cw;i++)
dtemp1=dtemp1->next;
c[0]=*(dtemp1->point);c[1]='\0';
strcpy(ctemp,p); strcat(ctemp,c);addtodictionary(ctemp,table);}
else {
dtemp1=table;
for(i=1;i<=pw;i++)
dtemp1=dtemp1->next;
strcpy(p,dtemp1->point);dtemp1=table;
for(i=1;i<=cw;i++)
dtemp1=dtemp1->next;
c[0]=*(dtemp1->point);c[1]='\0'; strcpy(ctemp,p); strcat(ctemp,c);
length=strlen(ctemp); fwrite(ctemp,sizeof(char),length,ofp);
addtodictionary(ctemp,table);}
}
}/*End The Expand()*/
现在我们所剩下的只有inthetable(),addtodictionary()和inthestringtable()三个子函数的实现问题了,按照自己事先所预定的函数功能,可以很容易给出这三个字函数的C语言描述:
int inthetable(char *c,struct cell *dic)
{char *ctemp;struct cell *table;int j=0;
ctemp=malloc(sizeof(char));strcpy(ctemp,c);table=dic;
while(table!=NULL)
{if(strcmp(table->point,ctemp)==0) return(j);/*存在*/
else{table=table->next;j++;}
}return(-1);/*不存在*/
}/* End the inthetable()*/
void addtodictionary(char *p,struct cell *dic)
{char *ctemp;struct cell *table,*dtemp;int i;ctemp=malloc(sizeof(char));
strcpy(ctemp,p);table=dic;
for(i=1;i<=n;i++)
table=table->next;
dtemp=(struct cell *)malloc(sizeof(struct cell)); strcpy(dtemp->point,ctemp);
table->next=dtemp;dtemp->next=NULL;n++;/*n为全局变量,用来纪录字典的长度*/
}/*End the addtodictionary()*/
int inthestringtable(int k,struct cell *dic)
{ struct cell *dtemp;int j=0;dtemp=dic;
while(dtemp->next!=NULL)
{ if(j<k) { dtemp=dtemp->next;j++;}
else if(j==k)return(j);/*存在*/
}if(j==k) return(j);
else return(-1);/*不存在*/
}
四、程序的进一步实现(源代码):
#include<stdio.h>
#include<string.h>
struct cell{
char point[100];
struct cell *next;}*dictionary;
void compress();
void expand();
void addtodictionary();
void *malloc();
int inthetable();
int inthestringtable();
int n=31;

main()
{ int choise,i; char *infilename,*outfilename;FILE *infile,*outfile;
struct cell *dtemp1,*dtemp2;
infilename=malloc(sizeof(char));outfilename=malloc(sizeof(char));
dictionary=(struct cell *)malloc(sizeof(struct cell));
*(dictionary->point)=44;*((dictionary->point)+1)='\0';
{dtemp1=(struct cell*)malloc(sizeof(struct cell));
dictionary->next=dtemp1;*(dtemp1->point)=46;*((dtemp1->point)+1)='\0';}
{dtemp2=(struct cell*)malloc(sizeof(struct cell));
dtemp1->next=dtemp2;*(dtemp2->point)=58;*((dtemp2->point)+1)='\0';dtemp1=dtemp2;}
{dtemp2=(struct cell*)malloc(sizeof(struct cell));
dtemp1->next=dtemp2;*(dtemp2->point)=59;*((dtemp2->point)+1)='\0';dtemp1=dtemp2;}
{dtemp2=(struct cell*)malloc(sizeof(struct cell));
dtemp1->next=dtemp2;*(dtemp2->point)=10;*((dtemp2->point)+1)='\0';dtemp1=dtemp2;}
{dtemp2=(struct cell*)malloc(sizeof(struct cell));
dtemp1->next=dtemp2;*(dtemp2->point)=13;*((dtemp2->point)+1)='\0';dtemp1=dtemp2;}
for(i=97;i<=122;i++)
{
dtemp2=(struct cell*)malloc(sizeof(struct cell));
dtemp1->next=dtemp2;dtemp2->next=NULL;
dtemp1=dtemp2;
*(dtemp2->point)=i;*((dtemp2->point)+1)='\0';
} /*Dui Ditionary Chu SHi Hua*/
printf("\n<1> for Compress.\n<2> for Expand.\n<0> for Exit!\n ");
printf("Please Input Your Choise:");
scanf("%d",&choise);
if(choise==1)
{
printf("\nPlease Input The Compressing File Name:");
scanf("%s",infilename);
if((infile=fopen(infilename,"rb"))==NULL)
{printf("Cannot open the %s file!\n",infilename);exit(1);}
printf("\nPlease Input The Name for the Compressed File:");
scanf("%s",outfilename);
if((outfile=fopen(outfilename,"wb"))==NULL)
{printf("Cannot open the %s file!\n",outfilename);exit(1);}
compress(infile,outfile,dictionary);/*Can Compress*/
fclose(infile);
fclose(outfile);
}
else if(choise==2)
{
printf("\nPlease Input THe Expanding File Name:");
scanf("%s",infilename);
if((infile=fopen(infilename,"rb"))==NULL)
{printf("Cannot open the %s file!\n",infilename);exit(1);}
printf("\nPlease INput the Name for THe Expanded File:");
scanf("%s",outfilename);
if((outfile=fopen(outfilename,"wb"))==NULL)
{printf("Cannot open the %s file!\n",outfilename);exit(1);}
/*if((infile=fopen(infilename,"rb"))==NULL||(outfile=fopen(outfilename,"wb"))==NULL)
{printf("Cannot Open THe %s File or The %s File!\n",infilename,outfilename);
exit(1);}
else*/ expand(infile,outfile,dictionary);/*Can Expand*/
fclose(infile);fclose(outfile);
}
else exit(1);
}
void compress(FILE *in,FILE *out,struct cell *dic)
{
FILE *ifp,*ofp;struct cell *table;char c[2],*ctemp,*p;int j;
ifp=in;ofp=out;table=dic;
ctemp=malloc(sizeof(char));p=malloc(sizeof(char));
p[0]='\0';c[0]=fgetc(ifp);c[1]='\0';
while(!feof(ifp))
{
strcpy(ctemp,p);
strcat(ctemp,c);
if((j=inthetable(ctemp,table))!=-1)
strcpy(p,ctemp);
else {
j=inthetable(p,table);
printf(" %d.",j);
fwrite(&j,sizeof(int),1,ofp);
addtodictionary(ctemp,table);
strcpy(p,c);
}
c[0]=fgetc(ifp);
}
j=inthetable(p,table);
printf(" %d.",j);
fwrite(&j,sizeof(int),1,ofp);
}/*End the Compress()*/

int inthetable(char *c,struct cell *dic)
{
char *ctemp;struct cell *table;int j=0;
ctemp=malloc(sizeof(char));
strcpy(ctemp,c);table=dic;
zhoukun666 2002-12-15
  • 打赏
  • 举报
回复
我的课程报告!唉!谁要你是美女呢!免费吧!
课程设计七:文本 LZW 压缩----数据结构
一、 设计要求:
根据 Lempel-Ziv-Welch Encoding ,简称 LZW 的压缩算法,用任何一中语言来实现它.

二、设计原理:
LZW压缩算法的基本概念:LZW压缩有三个重要的对象:数据流(CharStream)、编码流(CodeStream)和编译表(String Table)。在编码时,数据流是输入对象(文本文件的据序列),编码流就是输出对象(经过压缩运算的编码数据);在解码时,编码流则是输入对象,数据流是输出对象;而编译表是在编码和解码时都须要用借助的对象。字符(Character):最基础的数据元素,在文本文件中就是一个字节,在光栅数据中就是一个像素的颜色在指定的颜色列表中的索引值;字符串(String):由几个连续的字符组成; 前缀(Prefix):也是一个字符串,不过通常用在另一个字符的前面,而且它的长度可以为0;根(Root):一个长度的字符串;编码(Code):一个数字,按照固定长度(编码长度)从编码流中取出,编译表的映射值;图案:一个字符串,按不定长度从数据流中读出,映射到编译表条目.
LZW压缩算法的基本原理:提取原始文本文件数据中的不同字符,基于这些字符创建一个编译表,然后用编译表中的字符的索引来替代原始文本文件数据中的相应字符,减少原始数据大小。看起来和调色板图象的实现原理差不多,但是应该注意到的是,我们这里的编译表不是事先创建好的,而是根据原始文件数据动态创建的,解码时还要从已编码的数据中还原出原来的编译表.

三、程序的初步构思以及主体函数的C语言实现:
根据上面所述的LZW压缩算法的基本原理,我们可以在大体上把编码和译码的主体部分做成两个单独的编码器和译码器.
编码器(Compressor):
编码数据,第一步,初始化一个编译表,假设这个编译表的大小是12位的,也就是最多有4096个单位,另外假设我们有32个不同的字符(小写字母“a,b,……z“,标点符号“,。;:“和换行符以及回车),表示为a,b,c,d,e...,初始化编译表:第0项为a,第1项为b,第2项为c.……一直到第31项,我们把这32项就称为根。开始编译,先定义一个前缀对象Current Prefix,记为[.c.],现在它是空的,然后定义一个当前字符串Current String,标记为[.c.]k,[.c.]就为Current Prefix,k就为当前读取字符。在来读取数据流的第一个字符,假如为p,那么Current String就等于[.c.]p(由于[.c.]空,实际上值就等于p),现在在编译表中查找有没有Current String的值,由于p就是一个根字符,我们已经初始了32个根索引,当然可以找到,把p设为Current Prefix的值,不做任何事继续读取下一个字符,假设为q,Current String就等于[.c.]q(也就是pq),看看在编译表中有没有该值,当然。没有,这时我们要做下面的事情:将Current String的值(也就是pq)添加到编译表的第32项,把Current Prefix的值(也就是p)在编译表中的索引输出到编码流,修改Current Prefix为当前读取的字符(也就是q)。继续往下读,如果在编译表中可以查找到Current String的值([.c.]k),则把Current String的值([.c.]k)赋予Current Prefix;如果查找不到,则添加CurrentString的值([.c.]k)到编译表,把Current Prefix的值([.c.])在编译表中所对应的索引输出到编码流,同时修改Current Prefix为k ,这样一直循环下去直到数据流结束。伪代码看起来就像下面这样:
Initialize String Table;
[.c.] = Empty;
[.c.]k = First Character in CharStream;
while ([.c.]k != EOF )
{
  if ( [.c.]k is in the StringTable)
  {
    [.c.] = [.c.]k;
  }
  else
  {
    add [.c.]k to the StringTable;
    Output the Index of [.c.] in the StringTable to the CodeStream;
    [.c.] = k;
  }
  [.c.]k = Next Character in CharStream;
}
Output the Index of [.c.] in the StringTable to the CodeStream;

来看一个具体的例子,我们有一个字母表a,b,c,d.有一个输入的字符流abacaba。现在来初始化编译表:#0=a,#1=b,#2=c,#3=d.现在开始读取第一个字符a,[.c.]a=a,可以在在编译表中找到,修改[.c.]=a;不做任何事继续读取第二个字符b,[.c.]b=ab,在编译表中不能找,那么添加[.c.]b到编译表:#4=ab,同时输出[.c.](也就是a)的索引#0到编码流,修改[.c.]=b;读下一个字符a,[.c.]a=ba,在编译表中不能找到:添加编译表#5=ba,输出[.c.]的索引#1到编码流,修改[.c.]=a;读下一个字符c,[.c.]c=ac,在编译表中不能找到:添加编译表#6=ac,输出[.c.]的索引#0到编码流,修改[.c.]=c;读下一个字符a,[.c.]c=ca,在编译表中不能找到:添加编译表#7=ca,输出[.c.]的索引#2到编码流,修改[.c.]=a;读下一个字符b,[.c.]b=ab,编译表的#4=ab,修改[.c.]=ab;读取最后一个字符a,[.c.]a=aba,在编译表中不能找到:添加编译表#8=aba,输出[.c.]的索引#4到编码流,修改[.c.]=a;好了,现在没有数据了,输出[.c.]的值a的索引#0到编码流,这样最后的输出结果就是:#0#1#0#2#4#0.
现在参照上面的编码伪代码可以试着用所学的C语言来实现它:
void compress(FILE *in,FILE *out,struct cell *dic)
{FILE *ifp,*ofp;struct cell *table;char c[2],*ctemp,*p;int j;
ifp=in;ofp=out;table=dic;
ctemp=malloc(sizeof(char));p=malloc(sizeof(char));
p[0]='\0';c[0]=fgetc(ifp);c[1]='\0';
while(!feof(ifp))/*逐步单个字符读ifp文本文件知道文件结束*/
{ strcpy(ctemp,p);strcat(ctemp,c);
if((j=inthetable(ctemp,table))!=-1)/*函数inthetable(ctemp,table)是判断字符串ctemp是否在字典table中,它的返回值是ctem在字典table中的位置,但若ctemp不存在则返回-1.*/
strcpy(p,ctemp);
else {
j=inthetable(p,table);
fwrite(&j,sizeof(int),1,ofp);/*把整数j写入ofp文件中,ofp实指向被压缩文件的指针*/
addtodictionary(ctemp,table);/*函数addtodictionary(ctemp,table)是把字符串ctemp加入到字 table的尾部*/
strcpy(p,c); }
c[0]=fgetc(ifp);
} j=inthetable(p,table);
fwrite(&j,sizeof(int),1,ofp);
}/*End the Compress()*/
对于子函数inthetable()和addtodictionary我们可以暂时只要明确它们的功能,具体实现可以留在后面再做。
解码器(Decompressor)
好了,现在来看看解码数据。数据的解码,其实就是数据编码的逆向过程,要从
已经编译的数据(编码流)中找出编译表,然后对照编译表还原图象的光栅数据。
  首先,还是要初始化编译表。GIF文件的图象数据的第一个字节存储的就是LZW编
码的编码大小(一般等于图象的位数),根据编码大小,初始化编译表的根条目(从
0到2的编码大小次方),然后定义一个当前编码Current Code,记作[code],定义一
个Old Code,记作[old]。读取第一个编码到[code],这是一个根编码,在编译表中可
以找到,把该编码所对应的字符输出到数据流,[old]=[code];读取下一个编码到
[code],这就有两种情况:在编译表中有或没有该编码,我们先来看第一种情况:先
输出当前编码[code]所对应的字符串到数据流,然后把[old]所对应的字符(串)当成
前缀prefix [...],当前编码[code]所对应的字符串的第一个字符当成k,组合起来当
前字符串Current String就为[...]k,把[...]k添加到编译表,修改[old]=[code],
读下一个编码;我们来看看在编译表中找不到该编码的情况,回想一下编码情况:如
果数据流中有一个p[...]p[...]pq这样的字符串,p[...]在编译表中而p[...]p不在,
编译器将输出p[...]的索引而添加p[...]p到编译表,下一个字符串p[...]p就可以在
编译表中找到了,而p[...]pq不在编译表中,同样将输出p[...]p的索引值而添加
p[...]pq到编译表,这样看来,解码器总比编码器『慢一步』,当我们遇到p[...]p所
对应的索引时,我们不知到该索引对应的字符串(在解码器的编译表中还没有该索引,
事实上,这个索引将在下一步添加),这时需要用猜测法:现在假设上面的p[...]所
对应的索引值是#58,那么上面的字符串经过编译之后是#58#59,我们在解码器中读
到#59时,编译表的最大索引只有#58,#59所对应的字符串就等于#58所对应的字符串
(也就是p[...])加上这个字符串的第一个字符(也就是p),也就是p[...]p。事实上,
这种猜测法是很准确(有点不好理解,仔细想一想吧)。上面的解码过程用伪代码表
示就像下面这样:
解码器伪代码
Initialize String Table;
[code] = First Code in the CodeStream;
Output the String for [code] to the CharStream;
[old] = [code];
[code] = Next Code in the CodeStream;
while ([code] != EOF )
{
  if ( [code] is in the StringTable)
  {
    Output the String for [code] to the CharStream; // 输出[code]所对应的字符串
    [...] = translation for [old]; // [old]所对应的字符串
    k = first character of translation for [code]; // [code]所对应的字符串的第一个字符
    add [...]k to the StringTable;
    [old] = [code];
  }
  else
  {
    [...] = translation for [old];
    k = first character of [...];
    Output [...]k to CharStream;
    add [...]k to the StringTable;
    [old] = [code];
  }
  [code] = Next Code in the CodeStream;
}
现也用C语言来实现它:
void expand(FILE *in,FILE *out,struct cell *dic)
{FILE *ifp,*ofp;struct cell *table,*dtemp,*dtemp1;
int cw,pw,i,j,length,*w; char *ctemp,*p,c[2];
w=malloc(sizeof(int));ctemp=malloc(sizeof(char));p=malloc(sizeof(char));
ifp=in;ofp=out;table=dic; dtemp=table;
for(i=1;i<=31;i++)
dtemp=dtemp->next;
dtemp1=dtemp->next; dtem
zhoukun666 2002-12-15
  • 打赏
  • 举报
回复
http://www.vb365.com/download/sort.asp?typeid=85
有详细而且丰富的算法源码!
记得给分!

zzwu 2002-12-06
  • 打赏
  • 举报
回复
我也有LZW源码,70多K.如要,留个email地址.
howie 2002-12-05
  • 打赏
  • 举报
回复
LZW就是通过建立一个字符串表,用较短的代码来表示较长的字符串来实现压缩.
呵呵,图象处理课上是这么讲的:)
howie 2002-12-05
  • 打赏
  • 举报
回复
LZW压缩算法是Unisys的专利,有效期到2003年,所以对它的使用是有限制的

字符串和编码的对应关系是在压缩过程中动态生成的,并且隐含在压缩数据中,解压的时候根据表来进行恢复,算是一种无损压缩.

源码的话我这里有例子(c&c++),只是很长很麻烦.(当然不是我写的,呵呵)
我可以发到你的信箱里,不过最好用短消息告诉我
呵呵 安全第一 :)

33,027

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧