• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pylab.imsave函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pylab.imsave函数的典型用法代码示例。如果您正苦于以下问题:Python imsave函数的具体用法?Python imsave怎么用?Python imsave使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: plot_coefficient_images

def plot_coefficient_images(h5file, output_dir, data_file='Data.npz', x=None, y=None,problemtype="RobustGraphNet"):
    """
    Iterate through hdf5 file of fits, plotting the coefficients as images and slices of images.
    """
    # get ground truth
    Data = np.load(data_file)
    true_im = Data['sig_im']

    # get fit results
    f = h5py.File(h5file,'r')
    results = f[problemtype]

    # make appropriate directories for saving images
    if not os.path.isdir(output_dir):
        os.makedirs(output_dir)
    for k in results.keys():
        local_dir = output_dir + k
        if not os.path.isdir(local_dir):
            os.makedirs(local_dir)
            os.makedirs(local_dir + "/slice_plots/")
        # get coefficients and l1 values
        solution = results[k+'/coefficients'].value
        l1_path= results[k+'/l1vec'].value
        if x is None and y is None:
            x = np.sqrt(solution.shape[1])
            y = x # image is square
        # make plots
        for i in xrange(solution.shape[0]):
            im = solution[i,:].reshape((x,y),order='F')
            pl.imsave(local_dir + "/l1=" + str(l1_path[i]) + ".png", im)
            print "\t---> Saved coefficient image", i
            plot_image_slice(im, true_im, x_slice=45, out_path=local_dir+"/slice_plots/l1="+str(l1_path[i])+".png")
            print "\t---> Saved coefficient image slice", i
开发者ID:kieferkat,项目名称:neuroparser,代码行数:33,代码来源:test_graphnet.py


示例2: visualize_array

def visualize_array(array, title='Image', show=True, write=False):
    """ Visualize 3d and 4d array as image. filters (shape[2], shape[3])
    are stacked first horizontaly, then verticaly """

    assert(array.ndim == 3 or array.ndim == 4)
    array = normalize(array)  # this makes a copy

    if array.ndim == 3:
        array = construct_stacked_array(array)
    elif array.ndim == 4:
        array = construct_stacked_matrix(array)
    else:
        raise NotImplementedError()

    cm = pylab.gray()
    if show:
        fig = pylab.gcf()
        fig.canvas.set_window_title(title)
        pylab.axis('off')
        pylab.imshow(array, interpolation='nearest', cmap=cm)
        pylab.show()
        pylab.draw()

    if write:
        pylab.imsave(title + '.png', array, cmap=cm)
开发者ID:Exception4U,项目名称:theano-conv-semantic,代码行数:25,代码来源:visualize.py


示例3: demo_show_image

def demo_show_image():
    im3 = np.zeros(shape=(200,100),dtype=np.int)
    im3[15:15+10,15:15+10]=11
    print im3[15:15+10,15:15+10]
    stream=cStringIO.StringIO()
    imsave(stream,im3)
    return stream.getvalue()
开发者ID:XuChongBo,项目名称:pydemo,代码行数:7,代码来源:myimagelib.py


示例4: img2output

def img2output(img, cmap=DEFAULT_COLORMAP, output=None, show=False):
  """ Plots and saves the desired fractal raster image """
  if output:
    pylab.imsave(output, img, cmap=cmap)
  if show:
    pylab.imshow(img, cmap=cmap)
    pylab.show()
开发者ID:danilobellini,项目名称:fractals,代码行数:7,代码来源:fractal.py


示例5: writeToKml

def writeToKml(filename, arr2d, NSEW, rotation=0.0, vmin=None, vmax=None, cmap=None, format=None, origin=None, dpi=72):
    """
    writeToKml(filename, arr2d, NSEW, rotation=0.0, vmin=None, vmax=None, cmap=None, format=None, origin=None, dpi=None):
        NSEW=[north, south, east, west]
    """
    import os
    #check if filename has extension
    base,ext=os.path.splitext(filename);
    if len(ext)==0:
        ext='.kml'
    kmlFile=base+ext;
    pngFile=base+'.png';
    f=open(kmlFile,'w');
    f.write('<kml xmlns="http://earth.google.com/kml/2.1">\n')
    f.write('<Document>\n')
    f.write('<GroundOverlay>\n')
    f.write('        <visibility>1</visibility>\n')
    f.write('        <LatLonBox>\n')    
    f.write('                <north>%(#)3.4f</north>\n' % {"#":NSEW[0]})
    f.write('                <south>%(#)3.4f</south>\n'% {"#":NSEW[1]})
    f.write('                <east>%(#)3.4f</east>\n'% {"#":NSEW[2]})
    f.write('                <west>%(#)3.4f</west>\n'% {"#":NSEW[3]})
    f.write('                <rotation>%(#)3.4f</rotation>\n' % {"#":rotation})
    f.write('        </LatLonBox>')
    f.write('        <Icon>')
    f.write('                <href>%(pngFile)s</href>' % {'pngFile':pngFile})
    f.write('        </Icon>')
    f.write('</GroundOverlay>')
    f.write('</Document>')
    f.write('</kml>')
    f.close();
    #Now write the image
    plt.imsave(pngFile, arr2d,vmin=vmin, vmax=vmax, cmap=cmap, format=format, origin=origin, dpi=dpi)
开发者ID:Terradue,项目名称:adore-doris,代码行数:33,代码来源:__init__.py


示例6: test_with_file

def test_with_file(fn):
    im = pylab.imread(fn)
    if im.ndim > 2:
        im = numpy.mean(im[:, :, :3], 2)
    pylab.imsave("intermediate.png", im, vmin=0, vmax=1., cmap=pylab.cm.gray)
    r = test_inline(im)
    return r
开发者ID:braingram,项目名称:eyetracker,代码行数:7,代码来源:radial.py


示例7: AnalyseNSS

    def AnalyseNSS(self):
        if self.Mode=="Manual":
            files=QFileDialog(self)
            files.setWindowTitle('Non-Synchronised Segment Stripes')
            self.CurrentImages=files.getOpenFileNames(self,caption='Non-Synchronised Segment Stripes')

        SSSDlg1=SSSDlg.SSSWidget(self)
        SSSDlg1.Img1=DCMReader.ReadDCMFile(str(self.CurrentImages[0]))
        SSSDlg1.SSS1.axes.imshow(SSSDlg1.Img1,cmap='gray')

        SSSDlg1.Img2=DCMReader.ReadDCMFile(str(self.CurrentImages[1]))
        SSSDlg1.SSS2.axes.imshow(SSSDlg1.Img2,cmap='gray')

        SSSDlg1.Img3=DCMReader.ReadDCMFile(str(self.CurrentImages[2]))
        SSSDlg1.SSS3.axes.imshow(SSSDlg1.Img3,cmap='gray')

        SSSDlg1.Img4=DCMReader.ReadDCMFile(str(self.CurrentImages[3]))
        SSSDlg1.SSS4.axes.imshow(SSSDlg1.Img4,cmap='gray')

        SSSDlg1.ImgCombi=SSSDlg1.Img1+SSSDlg1.Img2+SSSDlg1.Img3+SSSDlg1.Img4
        SSSDlg1.SSSCombi.axes.imshow(SSSDlg1.ImgCombi,cmap='gray')

        EPIDType=np.shape(SSSDlg1.Img1)

        pl.imsave('NSS.jpg',SSSDlg1.ImgCombi)
        Img1=pl.imread('NSS.jpg')
        if EPIDType[0]==384:
            Img2=pl.imread('NSSOrgRefas500.jpg')
        else:
            Img2=pl.imread('NSSOrgRef.jpg')
        self.MSENSS=np.round(self.mse(Img1,Img2))

        if self.Mode=="Manual":
            SSSDlg1.exec_()
开发者ID:Jothy,项目名称:RTQA,代码行数:34,代码来源:Start.py


示例8: output_image

def output_image(image, fname):

    pylab.imsave(fname, image, cmap='gray')

    if not os.path.exists(fname):
        print("  ##################### WARNING #####################")
        print("  --> No image file at @ '{}' (expected) ...".format(fname))
开发者ID:carterbox,项目名称:tomopy,代码行数:7,代码来源:benchmark.py


示例9: makeTestPair

def makeTestPair(paths, homography, collection, location=".", size=(250,250), scale = 1.0) :
    """ Given a pair of paths to two images and a homography between them,
        this function creates two crops and calculates a new homography.
        input: paths [strings] (paths to images)
               homography [numpy.ndarray] (3 by 3 array homography)
               collection [string] (The name of the testset)
               location [string] (The location (path) of the testset
               size [(int, int)] (The size of an image crop in pixels)
               scale [double] (The scale by which we resize the crops after they've been cropped)
        out:   nothing
    """
    
    # Get width and height
    width, height = size
    
    # Load images in black/white
    images = map(loadImage, paths)
    
    # Crop part of first image and part of second image:
    (top_o, left_o) = (random.randint(0, images[0].shape[0]-height), random.randint(0, images[0].shape[1]-width))
    (top_n, left_n) = (random.randint(0, images[1].shape[0]-height), random.randint(0, images[1].shape[1]-width))
    
    # Get two file names
    c_path = getRandPath("%s/%s/" % (location, collection))
    if not exists(dirname(c_path)) : makedirs(dirname(c_path))
        
    # Make sure we save as gray
    pylab.gray()
    
    im1 = images[0][top_o: top_o + height, left_o: left_o + width]
    im2 = images[1][top_n: top_n + height, left_n: left_n + width]
    im1_scaled = imresize(im1, size=float(scale), interp='bicubic')
    im2_scaled = imresize(im2, size=float(scale), interp='bicubic')
    pylab.imsave(c_path + "_1.jpg", im1_scaled)
    pylab.imsave(c_path + "_2.jpg", im2_scaled)
    
    # Homography for transpose
    T1 = numpy.identity(3)
    T1[0,2] = left_o
    T1[1,2] = top_o
    
    # Homography for transpose back
    T2 = numpy.identity(3)
    T2[0,2] = -1*left_n
    T2[1,2] = -1*top_n
    
    # Homography for scale
    Ts = numpy.identity(3)
    Ts[0,0] = scale
    Ts[1,1] = scale
    
    # Homography for scale back
    Tsinv = numpy.identity(3)
    Tsinv[0,0] = 1.0/scale
    Tsinv[1,1] = 1.0/scale
    
    # Combine homographyies and save
    hom = Ts.dot(T2).dot(homography).dot(T1).dot(Tsinv)
    hom = hom / hom[2,2]
    numpy.savetxt(c_path, hom)
开发者ID:arnfred,项目名称:Mirror-Match,代码行数:60,代码来源:murals.py


示例10: main

def main(args):
    """
    DocString
    """
    dim = (1000, 1000)  # Dimensions de l'image de sortie
    xint = (-3, 3)  # Intervalle des parties réelles
    yint = (-3, 3)  # Intervalle des parties imaginaires
    iterate = 30  # Nombre d'itérations
    c = 1 + .1j  # Paramètre

    im = julia_build(dim, xint, yint, iterate, c)
    pl.imshow(im, cmap="nipy_spectral", origin="lower")
    pl.imsave("julia.png", im, cmap="nipy_spectral", format="png")
    pl.show()

    vertex = None
    i_image = 0
    while vertex != "exit":
        vertex = complex(input("Vertex supérieur gauche sous la forme\
                                x+yj (pixels) : "))
        size_int = float(input("Intervalle de pixels : "))
        xint = (remap(dim[1], xint[0], xint[1], vertex.real),
                remap(dim[1], xint[0], xint[1], vertex.real + size_int))
        yint = (remap(dim[0], yint[0], yint[1], vertex.imag),
                remap(dim[0], yint[0], yint[1], vertex.imag + size_int))
        im = julia_build(dim, xint, yint, iterate, c)
        pl.imshow(im, cmap="gnuplot")
        pl.imsave("julia{}.png".format(i_image), im,
                  cmap="nipy_spectral", format="png")
        pl.show()
        i_image += 1
    return 0
开发者ID:gabrielhdt,项目名称:dynamics_experiments,代码行数:32,代码来源:julia1.py


示例11: output_image

def output_image(image, fname):
    """Save an image and check that it exists afterward."""
    pylab.imsave(fname, image, cmap='gray')

    if not os.path.exists(fname):
        print("  ##################### WARNING #####################")
        print("  --> No image file at @ '{}' (expected) ...".format(fname))
开发者ID:tomopy,项目名称:tomopy,代码行数:7,代码来源:benchmark.py


示例12: saveImages

 def saveImages(self):
     for zoom in self.zooms:
         try:
             pylab.imsave('zoom' + str(zoom) + '_' + '_'.join(
                 time.asctime().split()) + '.png', self.images[zoom])
         except KeyError, diag:
             print diag
             print 'Can\'t save image at zoom %s, it\'s not in the dictionary.' % zoom
开发者ID:MartinSavko,项目名称:eiger,代码行数:8,代码来源:calibrator.py


示例13: visualize

def visualize(image_list, cluster):
    i = 0
    for image in image_list:
        image = np.reshape(image, (28,28))
        plt.figure()
        plt.imsave("./Results/Centroid_" + str(i) + "_for_" + str(cluster) + "_clusters", image, cmap='gray')
        i+=1
    plt.close('all')
开发者ID:andrew950468,项目名称:CS289A,代码行数:8,代码来源:utils.py


示例14: save_mean_sharpness_map

	def save_mean_sharpness_map(self, rows, cols, sharp, label):

		mean_sharp_map = np.zeros((rows, cols), np.float)
		for x, y in np.ndindex((rows, cols)):
			mean_sharp_map[x,y] = sharp[label[x,y]]
			
		pp.gray()
		pp.imsave("tiger_reg_sharp.jpg", mean_sharp_map)
开发者ID:luamct,项目名称:WebSci14,代码行数:8,代码来源:background.py


示例15: save_jpeg

def save_jpeg(fn, rgb, **kwargs):
    import pylab as plt
    import tempfile
    f,tempfn = tempfile.mkstemp(suffix='.png')
    os.close(f)
    plt.imsave(tempfn, rgb, **kwargs)
    cmd = 'pngtopnm %s | pnmtojpeg -quality 90 > %s' % (tempfn, fn)
    os.system(cmd)
    os.unlink(tempfn)
开发者ID:legacysurvey,项目名称:decals-web,代码行数:9,代码来源:utils.py


示例16: thumbnailForFolder

def thumbnailForFolder(targetFolderName, destFolderName):
	origFiles = [ f for f in listdir(targetFolderName) if isfile(join(targetFolderName,f)) ]

	for files in origFiles:
		if(files[-4:] == '.png'):
			print(files)
			originalImage = imread(targetFolderName + files)
			thumbnail = createThumbnail(originalImage)
			imsave(destFolderName+files[0:-4]+'.png', thumbnail)
开发者ID:AlinaKay,项目名称:ArchivIT,代码行数:9,代码来源:thumbnailForFolder.py


示例17: save_segmented_image

    def save_segmented_image(self, cleaned_contours):
        '''
        Saves image

        Parameters
        ----------
        cleaned_contours : nparray
            Processed graphcut output
        '''
        pylab.imsave(cleaned_contours)
开发者ID:mcverter,项目名称:Python_Image_Segmentation,代码行数:10,代码来源:ImageCreator.py


示例18: display_digit

def display_digit(label,X,colormap=pylab.cm.gist_gray):
    l = len(X)
    m = int(np.ceil(np.sqrt(l)))
    M = np.zeros((m,m)) 
    for i in range(m):
        M[i,:] = X[i*m:(i+1)*m]
    pylab.imshow(M, cmap=colormap)
    pylab.imsave(str(label)+".png",M)    
    pylab.axis('off')
    return M
开发者ID:AndyLiu0429,项目名称:ModernAnalysis,代码行数:10,代码来源:digit.py


示例19: save

 def save(filename, key, matrix):
     import os
     
     out_matrix = os.path.join(os.getcwd(),filename + ".mat")
     out_img = os.path.join(os.getcwd(), filename + ".png")
     savemat(out_matrix, {key: matrix})
     print out_matrix
     print out_img
     out_list.append(out_matrix)
     imsave(out_img, matrix.todense())
     out_list.append(out_img)
开发者ID:briancheung,项目名称:C-PAC,代码行数:11,代码来源:resting_state_centrality.py


示例20: img_transition

def img_transition(file1, file2, map_array, blk_siz=2, n=50):
    I = file2gray(file1)
    J = file2gray(file2)

    d = absolute(I - J)
    steps = linspace(d.min(), d.max(), n+1)

    for i, step in enumerate(steps):
        K = I * (d>step) + J * (d<step)
        # do something with K
        im_name = os.path.join(".", "output", "%s-%s-%02d.png" %(file1, file2, i))
        imsave(im_name, K, cmap=cm.gray)
开发者ID:dusual,项目名称:omnium-gatherum,代码行数:12,代码来源:img2ascii.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pylab.imshow函数代码示例发布时间:2022-05-25
下一篇:
Python pylab.imread函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap