當前位置: 首頁>>代碼示例>>Python>>正文


Python image.imsave方法代碼示例

本文整理匯總了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") 
開發者ID:Evolving-AI-Lab,項目名稱:deep_learning_for_camera_trap_images,代碼行數:19,代碼來源:resize.py

示例2: imsave

# 需要導入模塊: from matplotlib import image [as 別名]
# 或者: from matplotlib.image import imsave [as 別名]
def imsave(*args, **kwargs):
    return _imsave(*args, **kwargs) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:4,代碼來源:pyplot.py

示例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() 
開發者ID:jkulhanek,項目名稱:visual-navigation-agent-pytorch,代碼行數:28,代碼來源:explorer.py

示例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') 
開發者ID:reallongnguyen,項目名稱:Optical-Flow-Guided-Feature,代碼行數:41,代碼來源:test_convert_ucf11.py

示例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) 
開發者ID:Prasad9,項目名稱:TFHubSample,代碼行數:14,代碼來源:Infer.py

示例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) 
開發者ID:Prasad9,項目名稱:TFHubSample,代碼行數:8,代碼來源:Infer.py

示例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) 
開發者ID:Prasad9,項目名稱:TFHubSample,代碼行數:7,代碼來源:Augment.py

示例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) 
開發者ID:adamhajari,項目名稱:spyre,代碼行數:10,代碼來源:model.py


注:本文中的matplotlib.image.imsave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。