【发布时间】:2020-02-20 16:37:21
【问题描述】:
我有一叠 7 张 288 x 288 像素的图像,我已将它们转换为 3d NumPy 数组
newarray.shape = (288, 288, 7)
我想从 7 个图像中的每一个中绘制一个特定的像素值,并将其绘制为一个图形,其中 y 轴显示像素值,x 轴显示图像编号。
【问题讨论】:
我有一叠 7 张 288 x 288 像素的图像,我已将它们转换为 3d NumPy 数组
newarray.shape = (288, 288, 7)
我想从 7 个图像中的每一个中绘制一个特定的像素值,并将其绘制为一个图形,其中 y 轴显示像素值,x 轴显示图像编号。
【问题讨论】:
from matplotlib import pyplot as plt
import numpy as np
# NumPy array storing images
images = np.random.randint(0, 255, (288, 288, 7), np.uint8)
# Get pixel values across all images of pixel of interest
x, y = (8, 3)
pixels = images[y, x, :]
# Plot
plt.plot(np.arange(images.shape[2]), pixels)
plt.ylim(0, 255)
plt.title('Pixel values for x=' + str(x) + ', y=' + str(y))
plt.tight_layout()
plt.show()
输出:
希望有帮助!
----------------------------------------
System information
----------------------------------------
Platform: Windows-10-10.0.16299-SP0
Python: 3.8.1
Matplotlib: 3.2.0rc3
NumPy: 1.18.1
----------------------------------------
【讨论】: