<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: LZW Data Compression</title>
	<atom:link href="http://marknelson.us/1989/10/01/lzw-data-compression/feed/" rel="self" type="application/rss+xml" />
	<link>http://marknelson.us/1989/10/01/lzw-data-compression/</link>
	<description>Programming, mostly.</description>
	<lastBuildDate>Wed, 16 May 2012 08:30:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Mark Nelson</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-531138</link>
		<dc:creator>Mark Nelson</dc:creator>
		<pubDate>Tue, 01 May 2012 17:59:15 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-531138</guid>
		<description>Hi Robert,

Sorry, I didn&#039;t get a chance to address this properly until today - I was traveling.

First, I think using pseudocode was a bad idea on my part, but it was a long time ago, and that was a different me.
I&#039;ve got an updated version of the article that I think is a lot more trustworthy, and it only uses C++ code - no pseudocode. The decompress routine looks like this:
[C]
  unsigned int code;
  unsigned int next_code = 257;
  while ( in &gt;&gt; code ) {
    out &lt;&lt; strings[code];
    if ( previous_string.size() )
      strings[next_code++] = previous_string + strings[code][0];
    previous_string = strings[code];
  }
[/C]
In this case, previous_string is a standin for OLD_CODE, and it does exactly what you are saying it should do.

In the pseudo code, I am very casually going back and forth between strings and codes, which is a confusing mistake. So when I say OLD_CODE = NEW_CODE, I am doing so on the idea that NEW_CODE == STRING. Which it is, more or less, if you look up NEW_CODE in the library, you get STRING.

In any case, your correction is well taken, and as I say, I think the whole thing is a lot more clear and less prone to misinterpretation in the new article at:

http://marknelson.us/2011/11/08/lzw-revisited/

Thanks for your input, and thanks for reading.


- Mark</description>
		<content:encoded><![CDATA[<p>Hi Robert,</p>
<p>Sorry, I didn't get a chance to address this properly until today - I was traveling.</p>
<p>First, I think using pseudocode was a bad idea on my part, but it was a long time ago, and that was a different me.<br />
I've got an updated version of the article that I think is a lot more trustworthy, and it only uses C++ code - no pseudocode. The decompress routine looks like this:</p>
<div class="igBar"><span id="lc-1"><a href="#" onclick="javascript:showPlainTxt('c-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-1">
<div class="c">
<ol>
<li class="li1">
<div class="de1"><span class="kw4">unsigned</span> <span class="kw4">int</span> code;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw4">unsigned</span> <span class="kw4">int</span> next_code = <span class="nu0">257</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span> in&gt;&gt; code <span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; out &lt;&lt;strings<span class="br0">&#91;</span>code<span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> previous_string.<span class="me1">size</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; strings<span class="br0">&#91;</span>next_code++<span class="br0">&#93;</span> = previous_string + strings<span class="br0">&#91;</span>code<span class="br0">&#93;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; previous_string = strings<span class="br0">&#91;</span>code<span class="br0">&#93;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
In this case, previous_string is a standin for OLD_CODE, and it does exactly what you are saying it should do.</p>
<p>In the pseudo code, I am very casually going back and forth between strings and codes, which is a confusing mistake. So when I say OLD_CODE = NEW_CODE, I am doing so on the idea that NEW_CODE == STRING. Which it is, more or less, if you look up NEW_CODE in the library, you get STRING.</p>
<p>In any case, your correction is well taken, and as I say, I think the whole thing is a lot more clear and less prone to misinterpretation in the new article at:</p>
<p><a href="http://marknelson.us/2011/11/08/lzw-revisited/" rel="nofollow">http://marknelson.us/2011/11/08/lzw-revisited/</a></p>
<p>Thanks for your input, and thanks for reading.</p>
<p>- Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert K</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-529782</link>
		<dc:creator>Robert K</dc:creator>
		<pubDate>Mon, 30 Apr 2012 02:19:25 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-529782</guid>
		<description>How does that work with line 8 then?  &quot;add OLD_CODE + CHARACTER to the translation table&quot;

OLD_CODE needs to be a string in this context, no?  Sure seems like what you want is the old string value in this case, not the old (unresolved) lookup code.</description>
		<content:encoded><![CDATA[<p>How does that work with line 8 then?  "add OLD_CODE + CHARACTER to the translation table"</p>
<p>OLD_CODE needs to be a string in this context, no?  Sure seems like what you want is the old string value in this case, not the old (unresolved) lookup code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Nelson</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-529679</link>
		<dc:creator>Mark Nelson</dc:creator>
		<pubDate>Sun, 29 Apr 2012 23:57:10 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-529679</guid>
		<description>No.

Codes are integer values, which mostly start at 256 or 257 and increase montonically.

Strings are sequences of bytes.

So the assignment you propose doesn&#039;t work - it is assuming some kind of implicit conversion from one type to another, and that doesn&#039;t happen.

- Mark</description>
		<content:encoded><![CDATA[<p>No.</p>
<p>Codes are integer values, which mostly start at 256 or 257 and increase montonically.</p>
<p>Strings are sequences of bytes.</p>
<p>So the assignment you propose doesn't work - it is assuming some kind of implicit conversion from one type to another, and that doesn't happen.</p>
<p>- Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert K</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-529617</link>
		<dc:creator>Robert K</dc:creator>
		<pubDate>Sun, 29 Apr 2012 22:43:03 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-529617</guid>
		<description>I believe Line 9 of Figure 3 (decompression pseudocode):

[c]
OLD_CODE = NEW_CODE
[/c]

... should actually be:

[c]
OLD_CODE = STRING
[/c]

No?</description>
		<content:encoded><![CDATA[<p>I believe Line 9 of Figure 3 (decompression pseudocode):</p>
<div class="igBar"><span id="lc-2"><a href="#" onclick="javascript:showPlainTxt('c-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-2">
<div class="c">
<ol>
<li class="li1">
<div class="de1">OLD_CODE = NEW_CODE </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>... should actually be:</p>
<div class="igBar"><span id="lc-3"><a href="#" onclick="javascript:showPlainTxt('c-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C:</span>
<div id="c-3">
<div class="c">
<ol>
<li class="li1">
<div class="de1">OLD_CODE = <span class="kw4">STRING</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lzw算法</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-516867</link>
		<dc:creator>lzw算法</dc:creator>
		<pubDate>Wed, 11 Apr 2012 06:58:31 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-516867</guid>
		<description>[...] COMPRESSION》作者Mark Nelson的文章lzw data compression中介绍为：LZW compression replaces strings of characters with single codes. It does not do any [...]</description>
		<content:encoded><![CDATA[<p>[...] COMPRESSION》作者Mark Nelson的文章lzw data compression中介绍为：LZW compression replaces strings of characters with single codes. It does not do any [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Nelson</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-490886</link>
		<dc:creator>Mark Nelson</dc:creator>
		<pubDate>Wed, 07 Mar 2012 13:41:40 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-490886</guid>
		<description>@Usha:

If you need to send the table along with the indices, you aren&#039;t doing LZW, you are doing something else.

- Mark</description>
		<content:encoded><![CDATA[<p>@Usha:</p>
<p>If you need to send the table along with the indices, you aren't doing LZW, you are doing something else.</p>
<p>- Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Usha</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-490884</link>
		<dc:creator>Usha</dc:creator>
		<pubDate>Wed, 07 Mar 2012 13:40:10 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-490884</guid>
		<description>Hi Mark sir,
   I have implemented LZW algorithm in MATLAB.  I have  transformed the message file (say 1MB) to a coding table of code words(1.4MB) and a table of indexes(50KB) which points to position of the code word in decompressed file. I want to send the compressed data i.e Indexes file  on a wireless device. At the receiving end, how are we able to get the data stored in the coding Table? If we send that table also along with Indexes, size becomes double that of message file.  Please clarify.

Thanks in advance</description>
		<content:encoded><![CDATA[<p>Hi Mark sir,<br />
   I have implemented LZW algorithm in MATLAB.  I have  transformed the message file (say 1MB) to a coding table of code words(1.4MB) and a table of indexes(50KB) which points to position of the code word in decompressed file. I want to send the compressed data i.e Indexes file  on a wireless device. At the receiving end, how are we able to get the data stored in the coding Table? If we send that table also along with Indexes, size becomes double that of message file.  Please clarify.</p>
<p>Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: www.Phototalks.idv.tw &#187; LZW compression &#38; decompression</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-442414</link>
		<dc:creator>www.Phototalks.idv.tw &#187; LZW compression &#38; decompression</dc:creator>
		<pubDate>Mon, 02 Jan 2012 07:48:13 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-442414</guid>
		<description>[...] 期末考記錄用  參考自此但我覺得需要修改 [...]</description>
		<content:encoded><![CDATA[<p>[...] 期末考記錄用  參考自此但我覺得需要修改 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Nelson</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-384387</link>
		<dc:creator>Mark Nelson</dc:creator>
		<pubDate>Mon, 03 Oct 2011 20:03:51 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-384387</guid>
		<description>@Patrick:

Isn&#039;t that a question for the people who make Lan Messenger? I have no idea.</description>
		<content:encoded><![CDATA[<p>@Patrick:</p>
<p>Isn't that a question for the people who make Lan Messenger? I have no idea.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://marknelson.us/1989/10/01/lzw-data-compression/comment-page-6/#comment-384382</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Mon, 03 Oct 2011 19:57:51 +0000</pubDate>
		<guid isPermaLink="false">/1989/10/01/lzw-data-compression/#comment-384382</guid>
		<description>Hi Mark, I have one question for you, I hope you could help me with this.

It is possible to embed LZW algorithm in LAN Messenger because I want to Compress and Decompress file and embed it in LAN Messenger? I want to use a Visual Basic or Visual C# programming language. 

I hope you would reply immediately. Thank you.</description>
		<content:encoded><![CDATA[<p>Hi Mark, I have one question for you, I hope you could help me with this.</p>
<p>It is possible to embed LZW algorithm in LAN Messenger because I want to Compress and Decompress file and embed it in LAN Messenger? I want to use a Visual Basic or Visual C# programming language. </p>
<p>I hope you would reply immediately. Thank you.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

