问题标签 [lzw]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - 数组列表与 Java 中的字符串
我正在实现 LZW 算法。我已经成功地为字符串和文本文件实现了它,并且目前正在修改我的代码以使用二进制文件,例如图像或可执行文件(因为我无法将这些文件作为字符串读取)。
我已将String
代码中的类型替换为ArrayList<Byte>
类型。我的代码现在可以正确地压缩和解压缩二进制文件,但是它至少慢了 10 倍!这在速度是关键因素的压缩应用中是不可接受的。
我是否正确替换了ArrayList<Byte>
for String
。是否有具有类似功能的更快替代方案?请注意,LZW 算法需要调整数组大小,因此标准arrays[]
不适合。
问候。
java - Java LZW Compress working very slowly 20 seconds for 3MB
Here is my code:
{
}
I have worked from the article: http://marknelson.us/2011/11/08/lzw-revisited/
I have read some articles stating that this method is naive and very slow: https://code.google.com/p/algorithms-and-datastructures-course/source/browse/trunk/AD_exercise_4/src/ad_exercise_4/controller/LZWNaive.java?r=38
How can I speed up the algorithm. At the moment it is taking 21 seconds to compress 3MB. Could somebody provide the pseudocode that I should be following to achieve quicker results. For example 1-2 seconds to compress 3MB.
I think the !HashMap.containsKey() is the line which costs an extreme amount of time. 16 out of the 21 seconds.
Regards.
java - 使用 Java 中的块压缩大文件
我正在使用两种压缩算法的连续应用在 Java 中压缩超过 2GB 的文件;一个基于 LZ,一个基于 Huffman。(这类似于 DEFLATE)。
由于 2GB 太大而无法保存在任何缓冲区中,因此我必须通过输出临时文件的一种算法传递文件,然后通过输出最终文件的第二种算法传递该临时文件。
另一种方法是将文件压缩为 8MB 块(我没有收到 Out-Of-Memory 错误的大小),但是我无法充分利用整个文件中的冗余。
任何想法如何更整洁地执行这些操作。没有临时文件,也没有块压缩?是否有任何其他压缩工具以块为单位进行压缩?他们如何处理这个问题?问候
compression - 应用基于 LZ77 和 LZW 字典的压缩算法的软件
是否有执行基于字典的压缩算法(LZ77 和 LZW)的优秀应用程序(软件)。如果应用程序显示:压缩比,压缩和解压缩时间会更好。我想在文本文件中应用压缩并查看压缩后文件内容的变化。
谢谢
python - 模式查找 LZW python
LZW 算法用于查找输入符号之间的模式。但它能在词中寻找模式吗?我的意思是 alfabet 索引不是符号,而是例如输入的单词:
有一个像这样的输出:
或者是否有任何压缩算法可以解决问题?
java - 位包装 LZW 短语号
我目前正在研究 LZW 压缩的 java 实现。到目前为止,我的编码器工作正常。读取文件并输出将通过管道传送到位打包器的短语编号。
我现在必须将这些短语编号打包到一个文件中,我不确定如何进行此过程。此外,我们为编码设置的最大位为 20。因此,当编码的数字超过编码所需的 20 位时,我们重置特里树并开始构建新的特里树。
所以我们必须打包的第一组数字将是 0-255,然后是 256-511,依此类推,所以我知道有些将被打包为 8 位,然后是 9 位,依此类推。
如果可以就从哪里开始以及查看哪些内容提供任何指导,我们将不胜感激
go - Golang:无法使用 lzw 包解压数据
我正在尝试使用 Go 创建压缩字符串池。这是我的代码 - http://play.golang.org/p/T5usLfU0fA
我无法解压缩使用 compress/lzw 包压缩的 bin。lzw.Writer 的输入是 [104 101 108 108 111 32 119 111 114 108 100],lzw.Reader 的输出是 [0 1 0 0 3 0 3 3 2 0 0]。他们肯定不匹配。
我正在使用相同的参数(除了缓冲区)创建读取器和写入器。lzw.Reader 的缓冲区包含先前使用 lzw.Writer 压缩的数据。
php - 在 ASCII 文本文件上实现 LZW 需要帮助
我正在尝试实现 LZW 来压缩基于 ASCII 的文本文件,我需要帮助。
假设我有一个文本文件,上面写着“BABAABAAAA”,我使用我的代码使用 LZW 算法对其进行压缩。结果的输出将被写入一个文本文件,其结果是
现在的问题是,压缩文件的大小将比原始文件大,因为它将代码的每个字符都计算为单个字符,而不是将每个代码计算为单个整数。因此,它不是将 65 读取为 01000001,而是将 65 视为 2 个 ascii 字符,即 00110110 (6) 00110101 (5)。这甚至不包括标记('|')。
algorithm - LZW 压缩似乎无法正常工作
我正在尝试使此代码正常工作,但是当我尝试对事物进行编码时,它似乎无法正常工作。我有一个 60 字节的文本文件。我对其进行编码,输出文件为 100 字节。当我解码该文件时,它会变成 65 字节。它可以正确解码,但文件大小比原始文件大。我尝试对 jpg 进行编码并且文件大小确实下降了,但是之后我无法打开文件。我试图解码 jpg 文件,但它不起作用,似乎 cmd 已冻结。这是我试图使用的代码。
感谢任何帮助。谢谢。
java - LZW - Compression rate
Well, I have to make a PPM image compressor using the LZW algorithm, the algorithm and the code I understand and have implemented a version for strings (in Java,for tests).
The big problem is in compression, because if I have:
Input: ABCDABCDABCDABCD
Output: 65 66 67 68 256 258 260 259 257 68
as for my input I have 16 characters, if I just save my output as a text file, no compression because there are 34 characters. So I thought I'd save as binary file and then burn each field in a byte of my file, but there is the problem of fields >= 256. I also thought the idea of putting some fields set to occur when a value greater than 255 , something like that. :
(in this case I would remove the 255 field and 0 in my dictionary)
65 66 67 68 256 258 , would be:
65 66 67 68 255 1 0 255 3 0
then every field equal to 255 indicate an occurrence of consecutive bytes and sum would be the elements to be added; byte 0 indicates the end of sum.
The problem is that even so my output would be greater than the input and compression does not make sense. Then I would ask you if there is a way around this.