Python pylab 模块,imread() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用pylab.imread()

项目:ugali    作者:DarkEnergySurvey    | 项目源码 | 文件源码
def getSDSSImage(ra,dec,radius=1.0,xsize=800,opt='GML',**kwargs):
    """
    Download Sloan Digital Sky Survey images
    http://skyserver.sdss3.org/dr9/en/tools/chart/chart.asp

    radius (degrees)
    opts: (G) Grid, (L) Label, P (PhotoObj), S (SpecObj), O (Outline), (B) Bounding Box, 
          (F) Fields, (M) Mask, (Q) Plates, (I) Invert
    """
    import subprocess
    import tempfile

    url="http://skyservice.pha.jhu.edu/DR10/ImgCutout/getjpeg.aspx?"
    scale = 2. * radius * 3600. / xsize
    params=dict(ra=ra,dec=dec,
                width=xsize,height=xsize,
                scale=scale,opt=opt)
    query='&'.join("%s=%s"%(k,v) for k,v in params.items())

    tmp = tempfile.NamedTemporaryFile(suffix='.jpeg')
    cmd='wget --progress=dot:mega -O %s "%s"'%(tmp.name,url+query)
    subprocess.call(cmd,shell=True)
    im = pylab.imread(tmp.name)
    tmp.close()
    return im
项目:A-Neural-Algorithm-of-Artistic-Style    作者:kbedi95    | 项目源码 | 文件源码
def __init__(self, content_path, style_path):

        # 4D representations of the given content and style images
        self.content_image = utils.preprocess(plt.imread(content_path))[np.newaxis]
        self.style_image = utils.preprocess(plt.imread(style_path))[np.newaxis]

        # The session and graph used for evaluating the content and style of the
        # given content and style images
        self.evaluation_g = tf.Graph()
        self.evaluation_sess = tf.Session(graph=self.evaluation_g)

        # The outputs (:0) of the intermediate layers of the VGG16 model used to represent the
        # content and style of an input to the model
        self.content_layer = config["content_layer"]
        self.style_layers = config["style_layers"]

        with self.evaluation_g.as_default():

            # Import the VGG16 ImageNet predictor model graph into the evaluation_g member variable
            tf.import_graph_def(utils.get_vgg_model(), name="vgg")

            # The input to the VGG16 predictor model is the output (:0) of the first operation of the graph
            self.input_tensor = [op.name for op in self.evaluation_g.get_operations()][0] + ":0"
项目:slitSpectrographBlind    作者:aasensio    | 项目源码 | 文件源码
def __init__(self, lens_file=None, lens_psf_size=None, lens_grid_size=None):

    if lens_file:
      self.lens = True
      grid = scipy.misc.imread(lens_file, flatten=True)
      if np.max(grid) > 255:
        grid /= 2**(16-1)
      else:
        grid /= 255
      self.grid_gpu = cu.matrix_to_array(grid, 'C')
      self.lens_psf_size = lens_psf_size
      self.lens_grid_size = lens_grid_size
    else:
      self.lens = False
项目:ugali    作者:DarkEnergySurvey    | 项目源码 | 文件源码
def getDSSImage(ra,dec,radius=1.0,xsize=800,**kwargs):
    """
    Download Digitized Sky Survey images

    https://archive.stsci.edu/cgi-bin/dss_form    
    https://archive.stsci.edu/cgi-bin/dss_search

    Image is in celestial orientation (RA increases to the right)
    https://archive.stsci.edu/dss/script_usage.html

    ra (r) - right ascension
    dec (d) - declination
    equinox (e) - equinox (B1950 or J2000; default: J2000)
    height (h) - height of image (arcminutes; default: 15.0)
    width (w) - width of image (arcminutes; default: 15.0)
    format (f) - image format (FITS or GIF; default: FITS)
    compression (c) - compression (UNIX, GZIP, or NONE; default: NONE; compression 
         applies to FITS only)
    version (v)  - Which version of the survey to use:
         1  - First Generation survey (garden variety)
         2  - Second generation survey (incomplete)
         3  - Check the 2nd generation; if no image is available,
              then go to the 1st generation.
         4  - The Quick V survey (whence came the Guide Stars Catalog;
              used mostly for Phase II proposal submission)
    save (s)  - Save the file to disk instead of trying to display.
         (ON (or anything) or not defined; default: not defined.)
    """
    import subprocess
    import tempfile

    url="https://archive.stsci.edu/cgi-bin/dss_search?"
    scale = 2.0 * radius * 60.
    params=dict(ra='%.3f'%ra,dec='%.3f'%dec,width=scale,height=scale,
                format='gif',version=1)
    #v='poss2ukstu_red'
    query='&'.join("%s=%s"%(k,v) for k,v in params.items())

    tmp = tempfile.NamedTemporaryFile(suffix='.gif')
    cmd='wget --progress=dot:mega -O %s "%s"'%(tmp.name,url+query)
    subprocess.call(cmd,shell=True)
    im = pylab.imread(tmp.name)
    tmp.close()
    if xsize: im = scipy.misc.imresize(im,size=(xsize,xsize))
    return im

############################################################