武汉理工大学计算机数据结构与算法实验一——二叉树与哈夫曼图片压缩

上传者: m0_46249601 | 上传时间: 2021-06-03 13:02:12 | 文件大小: 48.54MB | 文件类型: 7Z
1.实验目的 通过“图片压缩编码”的编程实践,学习树、遍历二叉树、哈夫曼树、哈夫曼编码和他们的编程应用。 (1)掌握树的存储结构 (2)掌握二叉树的三种遍历方法 (3)掌握并理解Huffman树、Huffman编码等知识和应用 (4)掌握文件的操作 (5)使用Huffman算法实现图像压缩程序 2.实验内容 使用Huffman压缩算法,对一幅BMP格式的图片文件进行压缩。图片文件名为“Pic.bmp”,压缩后保存为“Pic.bmp.huf”文件。使用VS2010作为开发工具,开发一个控制台程序,使用Huffman压缩算法对图片文件“Pic.bmp”进行压缩。具体要求如下: (1)读取原文件,统计权值: 运行程序,输入文件名。 以“Pic.bmp”文件为例。若文件存放在F盘根目录下,输入文件完整路径“F:\Pic.bmp”。按回车结束。以字节流的方式,只读打“Pic.bmp”文件。 逐字节读取文件,统计文件中256种字节重复的次数,保存到一个数组中int weight[256]中。 (2)生成Huffman树 根据(1)中统计的结果,构建Huffman树。定义一个结构体来记录每个节点的权值、父节点、左孩子和右孩子。使用结构体数组来存储这个Huffman树。 (3)生成Huffman编码 遍历(2)中生成的Huffman树,记录256个叶子节点的Huffman编码,保存在字符串数组中。 (4)压缩原文件 使用Huffman编码对原文件中的字节重新编码,获得压缩后的文件数据。 (5)保存压缩文件 将编码过的数据,保存到文件“Pic.bmp.huf”中。

文件下载

资源详情

[{"title":"( 53 个子文件 48.54MB ) 武汉理工大学计算机数据结构与算法实验一——二叉树与哈夫曼图片压缩","children":[{"title":"Pic.bmp.huf <span style='color:#111;'> 146.17KB </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.sln <span style='color:#111;'> 1.44KB </span>","children":null,"spread":false},{"title":".vs","children":[{"title":"HuffmanCompressCpro","children":[{"title":"v16","children":[{"title":"ipch","children":[{"title":"AutoPCH","children":[{"title":"b5547bd8ab530aea","children":[{"title":"MENU.ipch <span style='color:#111;'> 34.13MB </span>","children":null,"spread":false}],"spread":true},{"title":"5ab5dab5927c122","children":[{"title":"MENU.ipch <span style='color:#111;'> 34.13MB </span>","children":null,"spread":false}],"spread":true},{"title":"3e5717ef8bb6b673","children":[{"title":"COMPRESS.ipch <span style='color:#111;'> 33.88MB </span>","children":null,"spread":false}],"spread":true},{"title":"e8d385f1196ce67d","children":[{"title":"MENU.ipch <span style='color:#111;'> 448.00KB </span>","children":null,"spread":false}],"spread":true},{"title":"33bceed1c87fd69d","children":[{"title":"DECOMPRESS.ipch <span style='color:#111;'> 384.00KB </span>","children":null,"spread":false}],"spread":true},{"title":"7628d1497d20a282","children":[{"title":"MAIN.ipch <span style='color:#111;'> 33.94MB </span>","children":null,"spread":false}],"spread":true},{"title":"bc318a6959e78cd8","children":[{"title":"HUFFMAN.ipch <span style='color:#111;'> 34.13MB </span>","children":null,"spread":false}],"spread":true},{"title":"71640d475738ade0","children":[{"title":"MAIN.ipch <span style='color:#111;'> 34.06MB </span>","children":null,"spread":false}],"spread":false},{"title":"c217aa61ee7d852c","children":[{"title":"DECOMPRESS.ipch <span style='color:#111;'> 33.88MB </span>","children":null,"spread":false}],"spread":false},{"title":"c1dd8ecaea0a26d9","children":[{"title":"COMPRESS.ipch <span style='color:#111;'> 33.94MB </span>","children":null,"spread":false}],"spread":false},{"title":"52cf218577b4e996","children":[{"title":"COMPRESS.ipch <span style='color:#111;'> 384.00KB </span>","children":null,"spread":false}],"spread":false},{"title":"423f2fac524811e","children":[{"title":"HUFFMAN.ipch <span style='color:#111;'> 33.88MB </span>","children":null,"spread":false}],"spread":false},{"title":"f251e5ab79fa572c","children":[{"title":"MAIN.ipch <span style='color:#111;'> 34.13MB </span>","children":null,"spread":false}],"spread":false},{"title":"9ce905023949898c","children":[{"title":"MENU.ipch <span style='color:#111;'> 33.94MB </span>","children":null,"spread":false}],"spread":false},{"title":"884975398971d343","children":null,"spread":false},{"title":"aa8bd39bdcf976fa","children":[{"title":"DECOMPRESS.ipch <span style='color:#111;'> 33.88MB </span>","children":null,"spread":false}],"spread":false}],"spread":false}],"spread":true},{"title":".suo <span style='color:#111;'> 56.50KB </span>","children":null,"spread":false},{"title":"Browse.VC.db <span style='color:#111;'> 6.00MB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":"Debug","children":[{"title":"HuffmanCompressCpro.exe <span style='color:#111;'> 84.50KB </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.ilk <span style='color:#111;'> 759.76KB </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.pdb <span style='color:#111;'> 932.00KB </span>","children":null,"spread":false}],"spread":true},{"title":"HuffmanCompressCpro","children":[{"title":"Main.cpp <span style='color:#111;'> 106B </span>","children":null,"spread":false},{"title":"Compress.h <span style='color:#111;'> 559B </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.vcxproj.user <span style='color:#111;'> 168B </span>","children":null,"spread":false},{"title":"Huffman.h <span style='color:#111;'> 984B </span>","children":null,"spread":false},{"title":"DeCompress.cpp <span style='color:#111;'> 3.26KB </span>","children":null,"spread":false},{"title":"Debug","children":[{"title":"HuffmanCompressCpro.vcxproj.FileListAbsolute.txt <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"Compress.obj <span style='color:#111;'> 72.50KB </span>","children":null,"spread":false},{"title":"HuffmanC.50697f27.tlog","children":[{"title":"CL.write.1.tlog <span style='color:#111;'> 5.22KB </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.lastbuildstate <span style='color:#111;'> 184B </span>","children":null,"spread":false},{"title":"link.command.1.tlog <span style='color:#111;'> 2.23KB </span>","children":null,"spread":false},{"title":"CL.read.1.tlog <span style='color:#111;'> 92.78KB </span>","children":null,"spread":false},{"title":"CL.command.1.tlog <span style='color:#111;'> 4.18KB </span>","children":null,"spread":false},{"title":"link.write.1.tlog <span style='color:#111;'> 1.38KB </span>","children":null,"spread":false},{"title":"link.read.1.tlog <span style='color:#111;'> 4.96KB </span>","children":null,"spread":false}],"spread":true},{"title":"HuffmanCompressCpro.log <span style='color:#111;'> 136B </span>","children":null,"spread":false},{"title":"vc142.pdb <span style='color:#111;'> 516.00KB </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.exe.recipe <span style='color:#111;'> 294B </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.Build.CppClean.log <span style='color:#111;'> 1.90KB </span>","children":null,"spread":false},{"title":"menu.obj <span style='color:#111;'> 107.30KB </span>","children":null,"spread":false},{"title":"Huffman.obj <span style='color:#111;'> 60.99KB </span>","children":null,"spread":false},{"title":"DeCompress.obj <span style='color:#111;'> 110.14KB </span>","children":null,"spread":false},{"title":"vc142.idb <span style='color:#111;'> 259.00KB </span>","children":null,"spread":false},{"title":"Main.obj <span style='color:#111;'> 31.48KB </span>","children":null,"spread":false}],"spread":false},{"title":"DeCompress.h <span style='color:#111;'> 489B </span>","children":null,"spread":false},{"title":"menu.cpp <span style='color:#111;'> 1.19KB </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.vcxproj <span style='color:#111;'> 7.38KB </span>","children":null,"spread":false},{"title":"menu.h <span style='color:#111;'> 143B </span>","children":null,"spread":false},{"title":"HuffmanCompressCpro.vcxproj.filters <span style='color:#111;'> 1.68KB </span>","children":null,"spread":false},{"title":"Huffman.cpp <span style='color:#111;'> 2.43KB </span>","children":null,"spread":false},{"title":"Compress.cpp <span style='color:#111;'> 4.02KB </span>","children":null,"spread":false}],"spread":false},{"title":"Pic.bmp <span style='color:#111;'> 863.54KB </span>","children":null,"spread":false}],"spread":true}]

评论信息

  • xiusiguwu :
    用户下载后在一定时间内未进行评价,系统默认好评。
    2021-11-12

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明