當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。