2 回答

TA貢獻(xiàn)1835條經(jīng)驗(yàn) 獲得超7個(gè)贊
你并不完全需numpy要這樣做,雖然我不知道是否有必要使用它,但有一種方法可以用簡(jiǎn)單的 Python 做到這一點(diǎn):
from PIL import Image
src_image = Image.open('test_image.png') # Image of size (28,28)
pixels = list(src_image.getdata()) # Get all pixel in 1D array.
dst_image = Image.new('RGB', (1,src_image.size[0] * src_image.size[1])) # Create new image with new size.
dst_image.putdata(pixels) # Place pixels in the new image.
dst_image.save('result.png') # Save the new image.

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊
如果您的問題是如何將多個(gè)圖像連接成一個(gè),其中每一行代表原始數(shù)據(jù)集中的一個(gè)圖像,那么 reshape + concatenate 應(yīng)該可以解決問題:
# all_images is a list / iterator of 28x28x3 numpy arrays
final_image = np.concatenate([img.reshape(1, -1, 3) for img in all_images])
添加回答
舉報(bào)