这是我的代码,它应该基于图像数据显示彩色图形,但我得到的是空白图形。 This is the Image I get when I pass the data
class plot_utils:
def __init__(self, img_data, title, num_pixels=10000, colors=None):
self.img_data = img_data
self.title = title
self.num_pixels = num_pixels
self.colors = colors
def colorSpace(self):
if self.colors is None:
self.colors = self.img_data
rand = np.random.RandomState(42)
index = rand.permutation(self.img_data.shape[0])[:self.num_pixels]
colors = self.colors[index]
R, G, B = self.img_data[index].T
fig, ax = plt.subplots(1, 2, figsize=(12,8))
ax[0].scatter(R, G, color=colors, marker='.')
ax[0].set(xlabel='Red', ylabel='Green', xlim=(0, 1), ylim=(0, 1))
ax[1].scatter(R, B, color=colors, marker='.')
ax[1].set(xlabel='Red', ylabel='Blue', xlim=(0, 1), ylim=(0, 1))
fig.suptitle(self.title, size=20)