简体   繁体   English

np.concatenate 不会连接

[英]np.concatenate won't concatenate

I'm trying to concatenate those 2 matrices 'Y' and 'I' but I can't understand what's wrong.我正在尝试连接这两个矩阵“Y”和“I”,但我不明白出了什么问题。 I took a black and white image and got the matrices 'Y', 'I' and 'Q', did some changes on the values of them and want to put them back together using 'np.concatenate()':我拍了一张黑白图像,得到了矩阵“Y”、“I”和“Q”,对它们的值进行了一些更改,并希望使用“np.concatenate()”将它们重新组合在一起:

Y = imYIQ[:, :, 0]
I = imYIQ[:, :, 1]
Q = imYIQ[:, :, 2]

normalized_Y = np.true_divide(Y, np.max(Y))

# Normalizes to [0, 1], stretches to [0, 2] and moves to the left to [-1, 1] both of 'I' and 'Q'
normalized_I = np.subtract(np.multiply(np.true_divide(I, np.max(I)), 2), 1)
normalized_Q = np.subtract(np.multiply(np.true_divide(Q, np.max(I)), 2), 1)

# Code crashes here:
concatenatedYI = np.concatenate(normalized_Y, normalized_I, axis=0)

The error that I get is:我得到的错误是:

TypeError: only integer scalar arrays can be converted to a scalar index

Does anyone understand what does this error mean in this context?有谁明白这个错误在这种情况下是什么意思? Thank you谢谢

The first argument to np.concatenate() is a sequence: np.concatenate()的第一个参数是一个序列:

np.concatenate([normalized_Y, normalized_I], axis=0)

See: https://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html请参阅: https://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM