<blockquote>
<p>Is Image.point() the right tool for
this job?</p>
</blockquote>
<p>是的,确实,<code>Image.point()</code>非常适合这个工作</p>
<blockquote>
<p>What format/structure does
Image.point() expect the table?</p>
</blockquote>
<p>您应该展平列表,而不是<code>[(12, 140, 10), (10, 100, 200), ...]</code>使用:</p>
<pre><code>[12, 140, 10, 10, 100, 200, ...]
</code></pre>
<p>下面是我刚刚尝试的一个快速示例:</p>
<pre><code>im = im.point(range(256, 0, -1) * 3)
</code></pre>
<p><img src="https://imgur.com/vUobW.png" alt="alt text"/>
<img src="https://imgur.com/3d6Y0.png" alt="alt text"/></p>
<p>顺便说一下,如果你需要更多的颜色控制并且你觉得Image.point不适合你,你也可以使用<code>Image.getdata</code>和<code>Image.putdata</code>来比<code>load</code>和<code>putpixel</code>更快地改变颜色。但它比<code>Image.point</code>慢。</p>
<p><code>Image.getdata</code>提供所有像素的列表,修改它们并使用<code>Image.putdata</code>将它们写回。就这么简单。但是,首先尝试使用<code>Image.point</code>来完成它。</p>
<hr/>
<p><strong>编辑</strong></p>
<p>我在第一个解释中出错了,现在我将正确解释:</p>
<p>颜色表实际上是这样的</p>
<pre><code>[0, 1, 2, 3, 4, 5, ...255, 0, 1, 2, 3, ....255, 0, 1, 2, 3, ...255]
</code></pre>
<p>每个波段都是相邻的。
要将颜色(0,0,0)更改为(10,100,10),需要如下所示:</p>
<pre><code>[10, 1, 2, 3, 4, 5, ...255, 100, 1, 2, 3, ....255, 10, 1, 2, 3, ...255]
</code></pre>
<p>要将颜色列表转换为正确的格式,请尝试以下操作:</p>
<pre><code>table = sum(zip(*colors), ())
</code></pre>
<p>我认为我的第一个例子应该为您演示格式。</p>