私は、次のコードスニペットに出くわした:私は最初の行に理解することができましたこのPythonコードをどのように解釈できますか?
output = numpy.zeros((max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], img1.shape[2]), dtype=img1.dtype)
output[:img1.shape[0], :img1.shape[1],:] = img1
output[:img2.shape[0]:,img1.shape[1]:img1.shape[1]+img2.shape[1],:] = img2
:
output = numpy.zeros((max(img1.shape[0], img2.shape[0]), img1.shape[1] + img2.shape[1], img1.shape[2]), dtype=img1.dtype)
をしかし、次の2行が何を意味するかを解釈できませんでした:
output[:img1.shape[0], :img1.shape[1],:] = img1
output[:img2.shape[0]:,img1.shape[1]:img1.shape[1]+img2.shape[1],:] = img2
アイデア
ご協力いただきありがとうございます。
これらは、配列が小さいインデックスです。 'a [:b、:c、:]'は、最初のインデックスが0からbまで、2番目が0からcまで、3番目が寸法。 –
お返事ありがとうございます。この声明はどうですか? :img2.shape [0] :(最後に ":"が表示されます)。 – Simplicity
コロンの後には何の効果もないと思います。範囲のステップを紹介します。デフォルトは1です。 –