-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_utils.py
24 lines (21 loc) · 911 Bytes
/
plot_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np
import matplotlib.pyplot as plt
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)