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


Python pyplot.gray方法代码示例

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


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

示例1: show_images_row

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def show_images_row(imgs, titles, rows=1):
    '''
       Display grid of cv2 images image
       :param img: list [cv::mat]
       :param title: titles
       :return: None
    '''
    assert ((titles is None) or (len(imgs) == len(titles)))
    num_images = len(imgs)

    if titles is None:
        titles = ['Image (%d)' % i for i in range(1, num_images + 1)]

    fig = plt.figure()
    for n, (image, title) in enumerate(zip(imgs, titles)):
        ax = fig.add_subplot(rows, np.ceil(num_images / float(rows)), n + 1)
        if image.ndim == 2:
            plt.gray()
        plt.imshow(image)
        ax.set_title(title)
        plt.axis('off')
    plt.show() 
开发者ID:albertpumarola,项目名称:GANimation,代码行数:24,代码来源:cv_utils.py

示例2: plot_figures

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def plot_figures(names, figures, nrows = 1, ncols=1):
    """Plot a dictionary of figures.

    Parameters
    ----------
    figures : <title, figure> dictionary
    ncols : number of columns of subplots wanted in the display
    nrows : number of rows of subplots wanted in the figure
    """

    fig, axeslist = plt.subplots(ncols=ncols, nrows=nrows)
    for ind,title in enumerate(names):
        img = np.squeeze(figures[title])
        if len(img.shape)==2:
            axeslist.ravel()[ind].imshow(img, cmap=plt.gray())#, cmap=plt.gray()
        else:
            axeslist.ravel()[ind].imshow(img)


        axeslist.ravel()[ind].set_title(title)
        axeslist.ravel()[ind].set_axis_off()
    plt.tight_layout() # optional

    plt.show() 
开发者ID:CVxTz,项目名称:medical_image_segmentation,代码行数:26,代码来源:plot_aug.py

示例3: display

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def display(images):
    '''
    Takes a list of [(name, image, grayscaleImage, (keypoints, descriptor))]
    and displays them in a grid two wide
    '''
    # Calculate the height of the the plt. This is the hundreds digit
    size = int(np.ceil(len(images)/2.))*100
    # Number of images across is the tens digit
    size += 20
    count = 1
    plt.gray()
    for imgName, img in images:
        if len(img.shape) == 3:
            img = img[::,::,::-1]
        plt.subplot(size + count)
        plt.imshow(img)
        plt.title(imgName)
        count += 1
    plt.show() 
开发者ID:agundy,项目名称:BusinessCardReader,代码行数:21,代码来源:utils.py

示例4: dispimsmovie_patchwise

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def dispimsmovie_patchwise(filename, M, inv, patchsize, fps=5, *args,
                           **kwargs):
    numframes = M.shape[0] / inv.shape[1]
    n = M.shape[0]/numframes

    def plotter(i):
        M_ = M[i*n:n*(i+1)]
        M_ = np.dot(inv,M_)
        width = int(np.ceil(np.sqrt(M.shape[1])))
        image = tile_raster_images(
            M_.T, img_shape=(patchsize,patchsize),
            tile_shape=(10,10), tile_spacing = (1,1),
            scale_rows_to_unit_interval = True, output_pixel_vals = True)
        plt.imshow(image,cmap=matplotlib.cm.gray,interpolation='nearest')
        plt.axis('off')

    CreateMovie(filename, plotter, numframes, fps) 
开发者ID:saebrahimi,项目名称:Emotion-Recognition-RNN,代码行数:19,代码来源:disptools.py

示例5: save_ims

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def save_ims(filename, ims, dpi=100):
    n, c, w, h = ims.shape
    x_plots = math.ceil(math.sqrt(n))
    y_plots = x_plots if n % x_plots == 0 else x_plots - 1
    plt.figure(figsize=(w*x_plots/dpi, h*y_plots/dpi), dpi=dpi)

    for i, im in enumerate(ims):
        plt.subplot(y_plots, x_plots, i+1)

        if c == 1:
            plt.imshow(im[0])
        else:
            plt.imshow(im.transpose((1, 2, 0)))

        plt.axis('off')
        plt.gca().set_xticks([])
        plt.gca().set_yticks([])
        plt.gray()
        plt.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0,
                            hspace=0)

    plt.savefig(filename, dpi=dpi*2, facecolor='black')
    plt.clf()
    plt.close() 
开发者ID:hvy,项目名称:chainer-wasserstein-gan,代码行数:26,代码来源:extensions.py

示例6: plot_examples

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def plot_examples(nade, dataset, shape, name, rows=5, cols=10):    
    #Show some samples
    images = list()
    for row in xrange(rows):                     
        for i in xrange(cols):
            nade.setup_n_orderings(n=1)
            sample = dataset.sample_data(1)[0].T
            dens = nade.logdensity(sample)
            images.append((sample, dens))
    images.sort(key=lambda x: -x[1])
    
    plt.figure(figsize=(0.5*cols,0.5*rows), dpi=100)
    plt.gray()            
    for row in xrange(rows):                     
        for col in xrange(cols):
            i = row*cols+col
            sample, dens = images[i]
            plt.subplot(rows, cols, i+1)
            plot_sample(np.resize(sample, np.prod(shape)).reshape(shape), shape, origin="upper")
    plt.subplots_adjust(left=0.01, right=0.99, top=0.99, bottom=0.01, hspace=0.04, wspace=0.04)
    type_1_font()
    plt.savefig(os.path.join(DESTINATION_PATH, name)) 
开发者ID:MarcCote,项目名称:NADE,代码行数:24,代码来源:analyse_orderless_NADE.py

示例7: plot_samples

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def plot_samples(nade, shape, name, rows=5, cols=10):    
    #Show some samples
    images = list()
    for row in xrange(rows):                     
        for i in xrange(cols):
            nade.setup_n_orderings(n=1)
            sample = nade.sample(1)[:,0]
            dens = nade.logdensity(sample[:, np.newaxis])
            images.append((sample, dens))
    images.sort(key=lambda x: -x[1])
    
    plt.figure(figsize=(0.5*cols,0.5*rows), dpi=100)
    plt.gray()            
    for row in xrange(rows):                     
        for col in xrange(cols):
            i = row*cols+col
            sample, dens = images[i]
            plt.subplot(rows, cols, i+1)
            plot_sample(np.resize(sample, np.prod(shape)).reshape(shape), shape, origin="upper")
    plt.subplots_adjust(left=0.01, right=0.99, top=0.99, bottom=0.01, hspace=0.04, wspace=0.04)
    type_1_font()
    plt.savefig(os.path.join(DESTINATION_PATH, name))                
    #plt.show() 
开发者ID:MarcCote,项目名称:NADE,代码行数:25,代码来源:analyse_orderless_NADE.py

示例8: inpaint_digits_

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def inpaint_digits_(dataset, shape, model, n_examples = 5, delete_shape = (10,10), n_samples = 5, name = "inpaint_digits"):    
    #Load a few digits from the test dataset (as rows)
    data = dataset.sample_data(1000)[0]
    
    #data = data[[1,12,17,81,88,102],:]
    data = data[range(20,40),:]
    n_examples = data.shape[0]
    
    #Plot it all
    matplotlib.rcParams.update({'font.size': 8})
    plt.figure(figsize=(5,5), dpi=100)
    plt.gray()
    cols = 2 + n_samples
    for row in xrange(n_examples):
        # Original
        plt.subplot(n_examples, cols, row*cols+1)
        plot_sample(data[row,:], shape, origin="upper")        
    plt.subplots_adjust(left=0.01, right=0.99, top=0.95, bottom=0.01, hspace=0.40, wspace=0.04)
    plt.savefig(os.path.join(DESTINATION_PATH, "kk.pdf")) 
开发者ID:MarcCote,项目名称:NADE,代码行数:21,代码来源:analyse_orderless_NADE.py

示例9: dispimsmovie_patchwise

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def dispimsmovie_patchwise(filename, M, inv, patchsize, fps=5, *args,
                           **kwargs):
    numframes = M.shape[0] / inv.shape[1]
    n = M.shape[0] / numframes

    def plotter(i):
        M_ = M[i * n:n * (i + 1)]
        M_ = np.dot(inv, M_)
        image = tile_raster_images(
            M_.T, img_shape=(patchsize, patchsize),
            tile_shape=(10, 10), tile_spacing=(1, 1),
            scale_rows_to_unit_interval=True, output_pixel_vals=True)
        plt.imshow(image, cmap=matplotlib.cm.gray, interpolation='nearest')
        plt.axis('off')

    CreateMovie(filename, plotter, numframes, fps) 
开发者ID:saebrahimi,项目名称:RATM,代码行数:18,代码来源:disptools.py

示例10: save_frames_to_png

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def save_frames_to_png(images, filepath):
    num_sequences, n_steps, w, h = images.shape

    if not os.path.exists(filepath):
        os.makedirs(filepath)

    for i in range(n_steps):
        f = plt.figure(figsize=[12, 12])
        plt.imshow(images[0, i], cmap=plt.gray(), interpolation='none')
        plt.savefig(filepath + '/img_%d.png' % i, format='png', bbox_inches='tight', dpi=80)
        plt.close(f) 
开发者ID:simonkamronn,项目名称:kvae,代码行数:13,代码来源:movie.py

示例11: display_hough

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def display_hough(h: float, a: List[float], d: List[float]) -> None:  # pylint: disable=invalid-name
    plt.imshow(
        np.log(1 + h),
        extent=[np.rad2deg(a[-1]), np.rad2deg(a[0]), d[-1], d[0]],
        cmap=plt.gray,
        aspect=1.0 / 90
    )
    plt.show() 
开发者ID:sbrunner,项目名称:deskew,代码行数:10,代码来源:plot.py

示例12: imwrite

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def imwrite(image, path):
    """Save an [-1.0, 1.0] image."""
    if image.ndim == 3 and image.shape[2] == 1:  # for gray image
        image = np.array(image, copy=True)
        image.shape = image.shape[0:2]
    return scipy.misc.imsave(path, to_range(image, 0, 255, np.uint8)) 
开发者ID:csmliu,项目名称:STGAN,代码行数:8,代码来源:basic.py

示例13: imshow

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def imshow(image):
    """Show a [-1.0, 1.0] image."""
    if image.ndim == 3 and image.shape[2] == 1:  # for gray image
        image = np.array(image, copy=True)
        image.shape = image.shape[0:2]
    plt.imshow(to_range(image), cmap=plt.gray()) 
开发者ID:csmliu,项目名称:STGAN,代码行数:8,代码来源:basic.py

示例14: show_multiple_figures_add

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def show_multiple_figures_add(fig, n, i, image, title, isGray=True):
    """ add <i>th (of n, start: 0) image to figure <fig> as subplot (GRAY)"""

    x = int(np.sqrt(n)+0.9999)
    y = int(n/x+0.9999)
    if(x*y<n):
        if x<y:
            x+=1
        else:
            y+=1

    ax = fig.add_subplot(x, y, i) #ith subplot in grid x,y
    ax.set_title(title)
    if isGray:
        plot.gray()
    ax.imshow(image,interpolation='nearest')

    return 0





#---------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------- 
开发者ID:GUR9000,项目名称:Deep_MRI_brain_extraction,代码行数:28,代码来源:NN_ConvNet.py

示例15: showImageGray

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import gray [as 别名]
def showImageGray(image_file):
    image_gray = cv2.imread(image_file, 0)
    plt.title('Gray')
    plt.gray()
    plt.imshow(image_gray)
    plt.axis('off')
    plt.show()


# HSVチャンネルの表示 
开发者ID:tody411,项目名称:PyIntroduction,代码行数:12,代码来源:color_space.py


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