擅长:python、mysql、java
<p>这是一艘很繁忙的单程邮轮,但在这里:</p>
<ol>
<li>首先确保NumPy数组<code>myarray</code>在<code>1.0</code>处使用最大值进行归一化</李>
<li>将颜色映射直接应用于<code>myarray</code></李>
<li>重新缩放到<code>0-255</code>范围</李>
<li>使用<code>np.uint8()</code>转换为整数</李>
<li>使用<code>Image.fromarray()</code></李>
</ol>
<p>你完成了:</p>
<pre><code>from PIL import Image
from matplotlib import cm
im = Image.fromarray(np.uint8(cm.gist_earth(myarray)*255))
</code></pre>
<p>与<code>plt.savefig()</code>一起:</p>
<p><img src="https://i.stack.imgur.com/PrTEI.png" alt="Enter image description here"/></p>
<p>与<code>im.save()</code>一起:</p>
<p><img src="https://i.stack.imgur.com/NRa20.png" alt="Enter image description here"/></p>