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


Python pylab.imsave函数代码示例

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


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


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