当前位置: 首页>>代码示例>>Python>>正文


Python pyplot.imsave方法代码示例

本文整理汇总了Python中matplotlib.pyplot.imsave方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.imsave方法的具体用法?Python pyplot.imsave怎么用?Python pyplot.imsave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.imsave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wishart_test

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def wishart_test(mode, ENL, percent):
    # Test statistic over the whole area
    w = Wishart(april, may, ENL, ENL, mode)

    # Test statistic over the no change region
    wno = Wishart(april.region(region_nochange), may.region(region_nochange), ENL, ENL, mode)

    # Histogram, no change region
    f, ax = wno.histogram(percent)
    hist_filename = "fig/wishart/{}/lnq.hist.ENL{}.pdf".format(mode, ENL)
    f.savefig(hist_filename, bbox_inches='tight')

    # Histogram, entire region
    f, ax = w.histogram(percent)
    hist_filename = "fig/wishart/{}/lnq.hist.total.ENL{}.pdf".format(mode, ENL)
    f.savefig(hist_filename, bbox_inches='tight')

    # Binary image
    im = w.image_binary(percent)
    plt.imsave("fig/wishart/{}/lnq.ENL{}.{}.jpg".format(mode, ENL, percent), im, cmap="gray") 
开发者ID:fouronnes,项目名称:SAR-change-detection,代码行数:22,代码来源:wishart.py

示例2: __call__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def __call__(self, result, out_dir, image_name):
        result_tool = ShowResultTool()
        result = result_tool(result)
        if 'GrayDisparity' in result.keys():
            grayEstDisp = result['GrayDisparity']
            gray_save_path = osp.join(out_dir, 'flow_0')
            mkdir_or_exist(gray_save_path)
            skimage.io.imsave(osp.join(gray_save_path, image_name), (grayEstDisp * 256).astype('uint16'))

        if 'ColorDisparity' in result.keys():
            colorEstDisp = result['ColorDisparity']
            color_save_path = osp.join(out_dir, 'color_disp')
            mkdir_or_exist(color_save_path)
            plt.imsave(osp.join(color_save_path, image_name), colorEstDisp, cmap=plt.cm.hot)

        if 'GroupColor' in result.keys():
            group_save_path = os.path.join(out_dir, 'group_flow')
            mkdir_or_exist(group_save_path)
            plt.imsave(osp.join(group_save_path, image_name), result['GroupColor'], cmap=plt.cm.hot) 
开发者ID:DeepMotionAIResearch,项目名称:DenseMatchingBenchmark,代码行数:21,代码来源:save_result.py

示例3: _custom_get

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def _custom_get(self, i, no, all_returns):

		for dataset_name, d in self.datasets_attr.items():
			if d['range'][0] <= i and d['range'][1] > i:
				image_root = d['image_root']
				d_name = dataset_name
				break

		image_new, link_new, target_new, weight_new, contour_i = self.aspect_resize(self.loader(image_root+'/'+self.images[i]), self.annots[i].copy(), self.remove_annots[i].copy())#, big_target_new
		image_new, target_new, link_new, contour_i = self.rotate(image_new, target_new, link_new, contour_i, 90)
		show = True
		if show:
			plt.imsave('img.png',image_new)
			num = np.array(image_new)
			cv2.drawContours(num, contour_i, -1, (0,255,0), 3)
			plt.imsave('contours.png',num)
			plt.imsave('target.png',target_new)
		img = self.transform(image_new).unsqueeze(0)
		target = self.target_transform(target_new).unsqueeze(0)
		link = self.target_transform(link_new).unsqueeze(0)
		weight = torch.FloatTensor(weight_new).unsqueeze(0).unsqueeze(0)
		all_returns[no] = [img, target, link, weight, contour_i, d_name] 
开发者ID:mayank-git-hub,项目名称:Text-Recognition,代码行数:24,代码来源:scale_two.py

示例4: create_annot1

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def create_annot1(self):

		all_paths = self.get_all_names_refresh()

		for i in all_paths:

			if os.path.exists(self.label_save_location+'.'.join(i.split('.')[:-1])+'.pkl'):
				continue
			print(i)
			image = Image.open(self.image_net_location+i).resize([768, 512]).convert('RGB')
			image = self.transparent(np.array(image),self.transparent_mean,self.transparent_gaussian)
			image = Image.fromarray(image.astype(np.uint8))
			final_image, coordinate_label ,label=self.generate_watermark_on_images(image)
			
			with open(self.label_save_location+'.'.join(i.split('.')[:-1])+'.pkl', 'wb') as f:
				pickle.dump([coordinate_label, label], f)
			plt.imsave(self.image_save_location+i, final_image) 
开发者ID:mayank-git-hub,项目名称:Text-Recognition,代码行数:19,代码来源:meta_artificial.py

示例5: prepare_visualize

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def prepare_visualize(result, epoch, work_dir, image_name):
    result_tool = ShowResultTool()
    result = result_tool(result)
    mkdir_or_exist(os.path.join(work_dir, image_name))
    save_path = os.path.join(work_dir, image_name, '{}.png'.format(epoch))
    plt.imsave(save_path, result['GroupColor'], cmap=plt.cm.hot)

    log_result = {}
    for pred_item in result.keys():
        log_name = image_name + '/' + pred_item
        if pred_item == 'Flow':
            log_result['image/' + log_name] = result[pred_item]
        if pred_item == 'GroundTruth':
            log_result['image/' + log_name] = result[pred_item]

    return log_result 
开发者ID:DeepMotionAIResearch,项目名称:DenseMatchingBenchmark,代码行数:18,代码来源:vis_hooks.py

示例6: __call__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def __call__(self, result, out_dir, image_name):
        result_tool = ShowResultTool()
        result = result_tool(result, color_map='gray', bins=100)

        if 'GrayDisparity' in result.keys():
            grayEstDisp = result['GrayDisparity']
            gray_save_path = osp.join(out_dir, 'disp_0')
            mkdir_or_exist(gray_save_path)
            skimage.io.imsave(osp.join(gray_save_path, image_name), (grayEstDisp * 256).astype('uint16'))

        if 'ColorDisparity' in result.keys():
            colorEstDisp = result['ColorDisparity']
            color_save_path = osp.join(out_dir, 'color_disp')
            mkdir_or_exist(color_save_path)
            plt.imsave(osp.join(color_save_path, image_name), colorEstDisp, cmap=plt.cm.hot)

        if 'GroupColor' in result.keys():
            group_save_path = os.path.join(out_dir, 'group_disp')
            mkdir_or_exist(group_save_path)
            plt.imsave(osp.join(group_save_path, image_name), result['GroupColor'], cmap=plt.cm.hot)

        if 'ColorConfidence' in result.keys():
            conf_save_path = os.path.join(out_dir, 'confidence')
            mkdir_or_exist(conf_save_path)
            plt.imsave(osp.join(conf_save_path, image_name), result['ColorConfidence']) 
开发者ID:DeepMotionAIResearch,项目名称:DenseMatchingBenchmark,代码行数:27,代码来源:save_result.py

示例7: log_images

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def log_images(self, tag, images, step):
        """Logs a list of images."""

        im_summaries = []
        for nr, img in enumerate(images):
            # Write the image to a string
            s = StringIO()
            plt.imsave(s, img, format='png')

            # Create an Image object
            img_sum = tf.Summary.Image(
                encoded_image_string=s.getvalue(),
                height=img.shape[0],
                width=img.shape[1])
            # Create a Summary value
            im_summaries.append(
                tf.Summary.Value(tag='%s/%d' % (tag, nr), image=img_sum))

        # Create and write Summary
        summary = tf.Summary(value=im_summaries)
        self.writer.add_summary(summary, step)
        self.writer.flush() 
开发者ID:akar43,项目名称:lsm,代码行数:24,代码来源:tensorboard_logging.py

示例8: do_batches

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def do_batches(self, fn, batch_generator, metrics):

        loss_total = 0
        batch_count = 0

        for i, batch in enumerate(tqdm(batch_generator)):
            inputs, targets, weights, _ = batch

            err, l2_loss, acc, dice, true, prob, prob_b = fn(inputs, targets, weights)

            metrics.append([err, l2_loss, acc, dice])
            metrics.append_prediction(true, prob_b)

            if i % 10 == 0:
                im = np.hstack((
                     true[:OUTPUT_SIZE**2].reshape(OUTPUT_SIZE,OUTPUT_SIZE),
                     prob[:OUTPUT_SIZE**2][:,1].reshape(OUTPUT_SIZE,OUTPUT_SIZE)))
                plt.imsave(os.path.join(self.image_folder,'{0}_epoch{1}.png'.format(metrics.name, self.epoch)),im)

            loss_total += err
            batch_count += 1

        return loss_total / batch_count 
开发者ID:gzuidhof,项目名称:luna16,代码行数:25,代码来源:unet_trainer.py

示例9: test_imsave_color_alpha

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def test_imsave_color_alpha():
    # Test that imsave accept arrays with ndim=3 where the third dimension is
    # color and alpha without raising any exceptions, and that the data is
    # acceptably preserved through a save/read roundtrip.
    from numpy import random
    random.seed(1)
    data = random.rand(256, 128, 4)

    buff = io.BytesIO()
    plt.imsave(buff, data)

    buff.seek(0)
    arr_buf = plt.imread(buff)

    # Recreate the float -> uint8 -> float32 conversion of the data
    data = (255*data).astype('uint8').astype('float32')/255
    # Wherever alpha values were rounded down to 0, the rgb values all get set
    # to 0 during imsave (this is reasonable behaviour).
    # Recreate that here:
    for j in range(3):
        data[data[:, :, 3] == 0, j] = 1

    assert_array_equal(data, arr_buf) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:25,代码来源:test_image.py

示例10: add_image

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def add_image(self, image):
        """
        Saves image to file.

        Args:
            image (HxWx3).

        Returns:
            str: filename.
        """
        if self.temp_dir is None:
            self.temp_dir = tempfile.mkdtemp()
        if self.img_shape is None:
            self.img_shape = image.shape
        assert self.img_shape == image.shape
        filename = self.get_filename(self.current_index)
        plt.imsave(fname=filename, arr=image)
        self.current_index += 1
        return filename 
开发者ID:jasonyzhang,项目名称:phd,代码行数:21,代码来源:video.py

示例11: plot_images

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def plot_images(images, shape, path, filename, n_rows = 10, color = True):
     # finally save to file
    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    images = reshape_and_tile_images(images, shape, n_rows)
    if color:
        from matplotlib import cm
        plt.imsave(fname=path+filename+".png", arr=images, cmap=cm.Greys_r)
    else:
        plt.imsave(fname=path+filename+".png", arr=images, cmap='Greys')
    #plt.axis('off')
    #plt.tight_layout()
    #plt.savefig(path + filename + ".png", format="png")
    print "saving image to " + path + filename + ".png"
    plt.close() 
开发者ID:nvcuong,项目名称:variational-continual-learning,代码行数:18,代码来源:visualisation.py

示例12: draw

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def draw(distance, objects, file_name):
    distance = distance.view(-1).cpu().numpy()
    objects = objects.view(-1).cpu().numpy()

    distance = np.around(distance / 4.0)
    distance[distance > 15] = 15

    screen = np.zeros([DoomObject.Type.MAX, 16, 32], dtype=np.float32)
    x = np.around(16 + tan * distance).astype(int)
    y = np.around(distance).astype(int)
    todelete = np.where(y == 15)
    y = np.delete(y, todelete, axis=0)
    x = np.delete(x, todelete, axis=0)
    channels = np.delete(objects, todelete, axis=0)
    screen[channels, y, x] = 1

    img = screen[[8, 7, 6], :]
    img = img.transpose(1, 2, 0)
    plt.imsave(file_name, img) 
开发者ID:akolishchak,项目名称:doom-net-pytorch,代码行数:21,代码来源:map_train.py

示例13: drawLines

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def drawLines(X1,X2,Y1,Y2,dis,img,num = 10):

    info = list(np.dstack((X1,X2,Y1,Y2,dis))[0])
    info = sorted(info,key=lambda x:x[-1])
    info = np.array(info)
    info = info[:min(num,info.shape[0]),:]
    img = Lines(img,info)
    #plt.imsave('./sift/3.jpg', img)

    if len(img.shape) == 2:
        plt.imshow(img.astype(np.uint8),cmap='gray')
    else:
        plt.imshow(img.astype(np.uint8))
    plt.axis('off')
    #plt.plot([info[:,0], info[:,1]], [info[:,2], info[:,3]], 'c')
    # fig = plt.gcf()
    # fig.set_size_inches(int(img.shape[0]/100.0),int(img.shape[1]/100.0))
    #plt.savefig('./sift/2.jpg')
    plt.show() 
开发者ID:o0o0o0o0o0o0o,项目名称:image-processing-from-scratch,代码行数:21,代码来源:SIFT.py

示例14: gabor_feature_single_job

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def gabor_feature_single_job(a, filters, fm_i, label, cluster_center_number, save_flag):
    # convolution
    start_time = time.time()
    # b=SN.correlate(a,filters[i]) # too slow
    b = signal.correlate(a, filters[fm_i], mode='same')
    end_time = time.time()
    print('feature %d done (%f s)' % (fm_i, end_time - start_time))

    # show Gabor filter output
    if save_flag:
        img = (b[:, :, int(a.shape[2] / 2)]).copy()
        plt.imsave('./result/gabor_output(%d).png' % fm_i, img, cmap='gray')  # save fig

    # generate feature vector
    start_time = time.time()
    result = generate_feature_vector(b=b, label=label, cluster_center_number=cluster_center_number)
    end_time = time.time()
    print('feature vector %d done (%f s)' % (fm_i, end_time - start_time))
    return fm_i, result 
开发者ID:xulabs,项目名称:aitom,代码行数:21,代码来源:saliency_detection.py

示例15: test_get_dataset_from_png

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import imsave [as 别名]
def test_get_dataset_from_png(self, _config):
        try:
            import matplotlib.pyplot as plt
        except ImportError:
            return

        datapath = _config.get('paths', 'dataset_path')
        classpath = os.path.join(datapath, 'class_0')
        os.mkdir(classpath)
        data = np.random.random_sample((10, 10, 3))
        plt.imsave(os.path.join(classpath, 'image_0.png'), data)

        _config.read_dict({
             'input': {'dataset_format': 'png',
                       'dataflow_kwargs': "{'target_size': (11, 12)}",
                       'datagen_kwargs': "{'rescale': 0.003922,"
                                         " 'featurewise_center': True,"
                                         " 'featurewise_std_normalization':"
                                         " True}"}})

        normset, testset = get_dataset(_config)
        assert all([normset, testset]) 
开发者ID:NeuromorphicProcessorProject,项目名称:snn_toolbox,代码行数:24,代码来源:test_io.py


注:本文中的matplotlib.pyplot.imsave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。