本文整理匯總了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)