本文整理汇总了Python中matplotlib.image.imsave方法的典型用法代码示例。如果您正苦于以下问题:Python image.imsave方法的具体用法?Python image.imsave怎么用?Python image.imsave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.image
的用法示例。
在下文中一共展示了image.imsave方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_chunk
# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import imsave [as 别名]
def do_chunk(pid,filelist):
for co,row in enumerate(filelist):
try:
if co%1000==0:
print(co)
sys.stdout.flush()
img=mpimg.imread(row)
img=scipy.misc.imresize(img[0:-100,:],(256,256))
path=dst_dir+str(row[len(src_dir):row.rfind('/')])
if not os.path.exists(path):
os.makedirs(path)
mpimg.imsave(dst_dir+row[len(src_dir):],img)
except:
print 'Severe Error for'+row
#raise
print("Process "+str(pid)+" is done")
示例2: imsave
# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import imsave [as 别名]
def imsave(*args, **kwargs):
return _imsave(*args, **kwargs)
示例3: show
# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import imsave [as 别名]
def show(self):
fig = plt.figure()
imgplot = plt.imshow(self.env.render(mode = 'image'))
def press(event):
def redraw():
plt.imshow(self.env.render(mode = 'image'))
fig.canvas.draw()
if event.key == 's':
mpimg.imsave("output.png",self.env.render(mode = 'image'))
elif event.key == 'up':
self.env.step('MoveAhead')
redraw()
elif event.key == 'right':
self.env.step('RotateRight')
redraw()
elif event.key == 'left':
self.env.step('RotateLeft')
redraw()
pass
plt.rcParams['keymap.save'] = ''
fig.canvas.mpl_connect('key_press_event', press)
plt.axis('off')
plt.show()
示例4: test
# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import imsave [as 别名]
def test():
print('Test read data')
dataset = ucf11.get_split('test', 'data/UCF11-tfrecord')
input, label = ucf11.build_data(dataset, 'train',batch_size=BATCH_SIZE)
new_input = off_preprocessing.preprocess_image(input, 240, 240, is_training=True)
example_queue = tf.FIFOQueue(
3 * BATCH_SIZE,
dtypes=[tf.float32, tf.uint8, tf.int32],
shapes=[_OUTPUT_SHAPES, _ORIGINAL_OUTPUT_SHAPES, []]
)
num_threads = 1
example_queue_op = example_queue.enqueue([new_input, input, label])
tf.train.add_queue_runner(tf.train.queue_runner.QueueRunner(
example_queue, enqueue_ops=[example_queue_op] * num_threads))
new_inputs, inputs, labels = example_queue.dequeue_many(BATCH_SIZE)
new_images = tf.unstack(new_inputs, axis=0)
print(new_images[0])
fx, fy = sobel(new_images[0])
spax = tf.unstack(fx, axis=0)
spay = tf.unstack(fy, axis=0)
print(fx)
print(fy)
print(spax)
with tf.Session() as sess:
tf.train.start_queue_runners(sess)
sx, sy, l = sess.run([spax[0], spay[0], labels])
for i in range(sx.shape[2]):
image.imsave('%d_fx%d' % (l[0], i), sx[:,:,i], cmap='gray')
image.imsave('%d_fy%d' % (l[0], i), sy[:,:,i], cmap='gray')
示例5: _plot_and_save
# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import imsave [as 别名]
def _plot_and_save(self, src_path, class_entities, boxes):
src_path = src_path.decode('ascii')
img = mpimg.imread(src_path)
shape = img.shape
for ce, b in zip(class_entities, boxes):
ce = ce.decode('ascii')
s1, s2, s3, s4 = int(b[1] * shape[1]), int(b[0] * shape[0]), int(b[3] * shape[1]), int(b[2] * shape[0])
cv2.rectangle(img, (s1, s2), (s3, s4), (0, 255, 0), 10)
cv2.putText(img, ce, (s1, s2), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2)
dst_path = os.path.join(self._save_path, os.path.basename(src_path))
mpimg.imsave(dst_path, img)
示例6: _save_images
# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import imsave [as 别名]
def _save_images(self, images):
for save_index, image in enumerate(images, self._save_index_at):
save_path = os.path.join(self._save_path, '{:05d}.jpg'.format(save_index))
mpimg.imsave(save_path, image)
self._save_index_at += len(images)
示例7: _save_image
# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import imsave [as 别名]
def _save_image(self, image, file_path, run_no):
file_path = file_path.decode('ascii')
file_name = os.path.splitext(os.path.basename(file_path))[0]
dst_file_path = os.path.join(self._dst_folder_path, '{}_{}.jpg'.format(file_name, run_no + 1))
mpimg.imsave(dst_file_path, image)
示例8: getImagePath
# 需要导入模块: from matplotlib import image [as 别名]
# 或者: from matplotlib.image import imsave [as 别名]
def getImagePath(self, img_obj):
buffer = io.BytesIO()
mpimg.imsave(buffer, img_obj)
try:
mpimg.imsave(buffer, img_obj)
except Exception:
logging.error("Error: getImage method must return an image object")
return(buffer)