具有特定块大小和最大运行长度的图像压缩
我需要编写两个名为 compress(S)
和 decompress(S)
的函数,它们将长度小于或等于 64 的二进制字符串 S 作为输入并返回另一个二进制文件字符串作为输出。输出二进制字符串应该是输入字符串的游程编码。
COMPRESSED_BLOCK_SIZE = 5
MAX_RUN_LENGTH = 2 ** COMPRESSED_BLOCK_SIZE - 1
>>>compress( 64*'0' )
'1111100000111110000000010'
>>>uncompress('1111100000111110000000010')
'64*0'
I need to write two functions called compress(S)
and decompress(S)
that take a binary string S of length less than or equal to 64 as input and return another binary string as output. The output binary string should be a run-length encoding of the input string.
COMPRESSED_BLOCK_SIZE = 5
MAX_RUN_LENGTH = 2 ** COMPRESSED_BLOCK_SIZE - 1
>>>compress( 64*'0' )
'1111100000111110000000010'
>>>uncompress('1111100000111110000000010')
'64*0'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论