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


Python pylab.imread方法代码示例

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


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

示例1: __init__

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def __init__(self, image_path, title, ignore_ssids=[]):
        self._image_path = image_path
        self._title = title
        self._ignore_ssids = ignore_ssids
        logger.debug(
            'Initialized HeatMapGenerator; image_path=%s title=%s',
            self._image_path, self._title
        )
        self._layout = imread(self._image_path)
        self._image_width = len(self._layout[0])
        self._image_height = len(self._layout) - 1
        logger.debug(
            'Loaded image with width=%d height=%d',
            self._image_width, self._image_height
        )
        with open('%s.json' % self._title, 'r') as fh:
            self._data = json.loads(fh.read())
        logger.info('Loaded %d measurement points', len(self._data)) 
开发者ID:jantman,项目名称:python-wifi-survey-heatmap,代码行数:20,代码来源:heatmap.py

示例2: predict_mask

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth=True):

    im = pylab.imread(image_file)

    net.blobs['images'].data[0] = preprocess(im, 321)
    net.forward()

    scores = np.transpose(net.blobs['fc8-prod'].data[0], [1, 2, 0])
    d1, d2 = float(im.shape[0]), float(im.shape[1])

    scores_exp = np.exp(scores - np.max(scores, axis=2, keepdims=True))
    probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)
    probs = nd.zoom(probs, (d1 / probs.shape[0], d2 / probs.shape[1], 1.0), order=1)

    eps = 0.00001
    probs[probs < eps] = eps

    if smooth:
        result = np.argmax(krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0), axis=2)
    else:
        result = np.argmax(probs, axis=2)

    return result 
开发者ID:speedinghzl,项目名称:DSRG,代码行数:25,代码来源:test.py

示例3: myimread

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def myimread(imgname, flip=False, resize=None):
    """
        read an image
    """
    img = None
    if imgname.split(".")[-1] == "png":
        img = pylab.imread(imgname)
    else:
        img = numpy.ascontiguousarray(pylab.imread(imgname)[::-1])
    if flip:
        img = numpy.ascontiguousarray(img[:, ::-1, :])
    if resize != None:
        from scipy.misc import imresize
        img = imresize(img, resize)
    return img 
开发者ID:po0ya,项目名称:face-magnet,代码行数:17,代码来源:util.py

示例4: predict_mask

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth=True):

    im = pylab.imread(image_file)
    d1, d2 = float(im.shape[0]), float(im.shape[1])

    scores_all = 0
    for size in [481]:
        im_process = preprocess(im, size)
        net.blobs['images'].reshape(*im_process.shape)
        net.blobs['images'].data[...] = im_process
        net.forward()
        scores = np.transpose(net.blobs['fc8-SEC'].data[0], [1, 2, 0])
        scores = nd.zoom(scores, (d1 / scores.shape[0], d2 / scores.shape[1], 1.0), order=1)
        scores_all += scores

    scores_exp = np.exp(scores_all - np.max(scores_all, axis=2, keepdims=True))
    probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)

    eps = 0.00001
    probs[probs < eps] = eps

    if smooth:
        result = np.argmax(krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0), axis=2)
        # result = np.argmax(dense_crf(probs, im), axis=2)
    else:
        result = np.argmax(probs, axis=2)

    return result.copy() 
开发者ID:speedinghzl,项目名称:DSRG,代码行数:30,代码来源:test-coco.py

示例5: predict_mask

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth, labels):

    im = pylab.imread(image_file)

    net.blobs['images'].data[0] = preprocess(im, 321)
    net.forward()

    scores = np.transpose(net.blobs['fc8-SEC'].data[0], [1, 2, 0])
    d1, d2 = float(im.shape[0]), float(im.shape[1])

    scores_exp = np.exp(scores - np.max(scores, axis=2, keepdims=True))
    probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)
    probs = nd.zoom(probs, (d1 / probs.shape[0], d2 / probs.shape[1], 1.0), order=1)

    eps = 0.00001
    probs[probs < eps] = eps

    if smooth:
        probs = krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0)
        
    labels = labels.tolist()
    labels.insert(0, 0)
    probs_selected = probs[:, :, labels]
    probs_c = np.argmax(probs_selected, axis=2)
    result = np.vectorize(lambda x: labels[x])(probs_c)
    prob_max = np.max(probs, axis=2)
    # result[prob_max < 0.85] = 255

    return result 
开发者ID:speedinghzl,项目名称:DSRG,代码行数:31,代码来源:generate_train_gt.py

示例6: predict_mask

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth=True):

    im = pylab.imread(image_file)
    d1, d2 = float(im.shape[0]), float(im.shape[1])

    scores_all = 0
    for size in [0.75, 1, 1.25]: #[385, 513, 641]
        im_process = preprocess(im, size)
        net.blobs['images'].reshape(*im_process.shape)
        net.blobs['images'].data[...] = im_process
        net.forward()
        scores = np.transpose(net.blobs['fc8-SEC'].data[0], [1, 2, 0])
        scores = nd.zoom(scores, (d1 / scores.shape[0], d2 / scores.shape[1], 1.0), order=1)
        scores_all += scores

    scores_exp = np.exp(scores_all - np.max(scores_all, axis=2, keepdims=True))
    probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)

    eps = 0.00001
    probs[probs < eps] = eps

    if smooth:
        result = np.argmax(krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0), axis=2)
        # result = np.argmax(dense_crf(probs, im), axis=2)
    else:
        result = np.argmax(probs, axis=2)

    return result 
开发者ID:speedinghzl,项目名称:DSRG,代码行数:30,代码来源:test-ms-f.py

示例7: predict_mask

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def predict_mask(image_file, smooth=True):

    im = pylab.imread(image_file)
    d1, d2 = float(im.shape[0]), float(im.shape[1])

    scores_all = 0
    for size in [241, 321, 401]:
        im_process = preprocess(im, size)
        net.blobs['images'].reshape(*im_process.shape)
        net.blobs['images'].data[...] = im_process
        net.forward()
        scores = np.transpose(net.blobs['fc8-SEC'].data[0], [1, 2, 0])
        scores = nd.zoom(scores, (d1 / scores.shape[0], d2 / scores.shape[1], 1.0), order=1)
        scores_all += scores

    scores_exp = np.exp(scores_all - np.max(scores_all, axis=2, keepdims=True))
    probs = scores_exp / np.sum(scores_exp, axis=2, keepdims=True)

    eps = 0.00001
    probs[probs < eps] = eps

    if smooth:
        result = np.argmax(krahenbuhl2013.CRF(im, np.log(probs), scale_factor=1.0), axis=2)
        # result = np.argmax(dense_crf(probs, im), axis=2)
    else:
        result = np.argmax(probs, axis=2)

    return result 
开发者ID:speedinghzl,项目名称:DSRG,代码行数:30,代码来源:test-ms.py

示例8: load

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def load(im_fname, gray = False):
  if im_fname.endswith('.gif'):
    print "GIFs don't load correctly for some reason"
    ut.fail('fail')
  im = from_pil(Image.open(im_fname))
  # use imread, then flip upside down
  #im = np.array(list(reversed(pylab.imread(im_fname)[:,:,:3])))
  if gray:
    return luminance(im)
  elif not gray and np.ndim(im) == 2:
    return rgb_from_gray(im)
  else:
    return im 
开发者ID:andrewowens,项目名称:multisensory,代码行数:15,代码来源:img.py

示例9: get_model_download

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import imread [as 别名]
def get_model_download(self, model_id, filename=None,
        output_filename=None):
        """Download a particular file associated with a given model or all its
        files as a COMBINE archive.

        :param model_id: a valid BioModels identifier
        :param str filename: this is the requested filename to be found in the
            model
        :param str output_filename: if you request a different output filename,
            use this parameter
        :param frmt: format of the output (json, xml, html)
        :return:  nothing. This function save the model into a ZIP file called
            after the model identifier. If parameter *filename* is specified, 
            then the output file is the requested filename (if found)

        ::

            bm.get_model_download("BIOMD0000000100", filename="BIOMD0000000100.png")
            bm.get_model_download("BIOMD0000000100")


        This function can retrieve all files in a ZIP archive or a single image.
        In the example below, we retrieve the PNG and plot it using matplotlib.
        Using your favorite image viewver, you should get a better resolution.
        Or just download the SVG version of the model.

        .. plot::
            :include-source:

            from bioservices import BioModels
            bm = BioModels()
            from easydev import TempFile
            with TempFile(suffix=".png") as fout:
                bm.get_model_download("BIOMD0000000100",
                        filename="BIOMD0000000100.png",
                        output_filename=fout.name)
                from pylab import imshow, imread
                imshow(imread(fout.name), aspect="auto")
        """
        params = {}
        if filename:
            params["filename"] = filename

        res = self.http_get("model/download/{}".format(model_id),  
            params=params)

        if filename:
            self.logging.info("Saving {}".format(filename))
            if output_filename is None:
                output_filename = filename
            with open(output_filename, "wb") as fout:
                fout.write(res.content)
        else:
            self.logging.info("Saving file {}.zip".format(model_id) )
            if output_filename is None:
                output_filename = "{}.zip".format(model_id)
            with open(output_filename, "wb") as fout:
                fout.write(res.content) 
开发者ID:cokelaer,项目名称:bioservices,代码行数:60,代码来源:biomodels.py


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