擅长:python、mysql、java
<p>有一种方法可以用<a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.sum.html" rel="nofollow">^{<cd1>}</a>一次求和</p>
<pre><code>DeltaRed, DeltaGreen, DeltaBlue = Orginal.sum((0,1)) - Mutated.sum((0,1))
</code></pre>
<p>这是另一个使用<a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html" rel="nofollow">^{<cd2>}</a>的,希望更快,当使用<code>uint8</code>图像时-</p>
<pre><code>org_diff = np.einsum('ijk->k',Orginal.astype('uint64'))
mut_diff = np.einsum('ijk->k',Mutated.astype('uint64'))
DeltaRed, DeltaGreen, DeltaBlue = org_diff - mut_diff
</code></pre>