-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutility.py
32 lines (27 loc) · 1.08 KB
/
utility.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
25
26
27
28
29
30
31
32
import skimage.io as io
import matplotlib.pyplot as plt
import numpy as np
# Show the figures / plots inside the notebook
def show_images(images,titles=None):
#This function is used to show image(s) with titles by sending an array of images and an array of associated titles.
# images[0] will be drawn with the title titles[0] if exists
# You aren't required to understand this function, use it as-is.
n_ims = len(images)
if titles is None: titles = ['(%d)' % i for i in range(1,n_ims + 1)]
fig = plt.figure()
n = 1
for image,title in zip(images,titles):
a = fig.add_subplot(1,n_ims,n)
if image.ndim == 2:
plt.gray()
plt.imshow(image)
a.set_title(title)
n += 1
fig.set_size_inches(np.array(fig.get_size_inches()) * n_ims)
plt.show()
#############################################################################
def vertical_histogram(img):
return np.sum(img, axis=0)
#############################################################################
def horizontal_histogram(img):
return np.sum(img, axis=1)