擅长:python、mysql、java
<p>您可以使用<a href="https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.dstack.html" rel="nofollow noreferrer">np.dstack</a>:</p>
<pre><code>import numpy as np
image = np.random.randint(100, size=(100, 100, 3))
r, g, b = image[:, :, 0], image[:, :, 1], image[:, :, 2]
result = np.dstack((r, g, b))
print("image shape", image.shape)
print("result shape", result.shape)
</code></pre>
<p><strong>输出</strong></p>
^{pr2}$