3
3
import os
4
4
5
5
import numpy as np
6
- import scipy . misc # save/read image(s)
6
+ import imageio # save/read image(s)
7
7
8
8
from . import _logging as logging
9
9
from . import prepro
@@ -44,7 +44,7 @@ def read_image(image, path=''):
44
44
The image.
45
45
46
46
"""
47
- return scipy . misc .imread (os .path .join (path , image ))
47
+ return imageio .imread (os .path .join (path , image ))
48
48
49
49
50
50
def read_images (img_list , path = '' , n_threads = 10 , printable = True ):
@@ -90,9 +90,9 @@ def save_image(image, image_path='_temp.png'):
90
90
91
91
"""
92
92
try : # RGB
93
- scipy . misc . imsave (image_path , image )
93
+ imageio . imwrite (image_path , image )
94
94
except Exception : # Greyscale
95
- scipy . misc . imsave (image_path , image [:, :, 0 ])
95
+ imageio . imwrite (image_path , image [:, :, 0 ])
96
96
97
97
98
98
def save_images (images , size , image_path = '_temp.png' ):
@@ -108,11 +108,6 @@ def save_images(images, size, image_path='_temp.png'):
108
108
image_path : str
109
109
save path
110
110
111
- Returns
112
- -------
113
- numpy.array
114
- The image.
115
-
116
111
Examples
117
112
---------
118
113
>>> images = np.random.rand(64, 100, 100, 3)
@@ -124,15 +119,15 @@ def save_images(images, size, image_path='_temp.png'):
124
119
125
120
def merge (images , size ):
126
121
h , w = images .shape [1 ], images .shape [2 ]
127
- img = np .zeros ((h * size [0 ], w * size [1 ], 3 ))
122
+ img = np .zeros ((h * size [0 ], w * size [1 ], 3 ), dtype = images . dtype )
128
123
for idx , image in enumerate (images ):
129
124
i = idx % size [1 ]
130
125
j = idx // size [1 ]
131
126
img [j * h :j * h + h , i * w :i * w + w , :] = image
132
127
return img
133
128
134
129
def imsave (images , size , path ):
135
- return scipy . misc . imsave (path , merge (images , size ))
130
+ return imageio . imwrite (path , merge (images , size ))
136
131
137
132
if len (images ) > size [0 ] * size [1 ]:
138
133
raise AssertionError ("number of images should be equal or less than size[0] * size[1] {}" .format (len (images )))
0 commit comments