當前位置: 首頁>>代碼示例>>Python>>正文


Python Image.frombytes方法代碼示例

本文整理匯總了Python中Image.frombytes方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.frombytes方法的具體用法?Python Image.frombytes怎麽用?Python Image.frombytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Image的用法示例。


在下文中一共展示了Image.frombytes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: arrayToImage

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import frombytes [as 別名]
def arrayToImage(a):
    """
    Converts a gdalnumeric array to a
    Python Imaging Library Image.
    """
    i=Image.frombytes('L',(a.shape[1],a.shape[0]),
            (a.astype('b')).tostring())
    return i 
開發者ID:Kirubaharan,項目名稱:hydrology,代碼行數:10,代碼來源:streams_milli.py

示例2: renderArea

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import frombytes [as 別名]
def renderArea(self, width, height, srs, xmin, ymin, xmax, ymax, zoom):
        '''
        '''

        # NB: To be thread-safe Map object cannot be stored in the class state.
        # see: https://groups.google.com/forum/#!topic/mapnik/USDlVfSk328

        Map = mapnik.Map(width, height, srs)
        Map.zoom_to_box(Box2d(xmin, ymin, xmax, ymax))

        Map = self.style_map(Map)

        img = mapnik.Image(width, height)
        # Don't even call render with scale factor if it's not
        # defined. Plays safe with older versions.
        if self.scale_factor is None:
            mapnik.render(Map, img)
        else:
            mapnik.render(Map, img, self.scale_factor)

        def gamma_correct(im):
            """Fast gamma correction with PIL's image.point() method."""
            if self.gamma != 1.0:
                table = [pow(x / 255., 1.0 / self.gamma) * 255
                         for x in range(256)]
                # Expand table to number of bands
                table = table * len(im.mode)
                return im.point(table)
            else:
                return im

        # b = BytesIO(img.tostring())
        img = Image.frombytes('RGBA', (width, height), img.tostring())

        img = gamma_correct(img)

        return img 
開發者ID:OpenGeoscience,項目名稱:geonotebook,代碼行數:39,代碼來源:provider.py

示例3: arrayToImage

# 需要導入模塊: import Image [as 別名]
# 或者: from Image import frombytes [as 別名]
def arrayToImage(a):
    """
    Converts a gdalnumeric array to a
    Python Imaging Library Image.
    """
    i=Image.frombytes('L',(a.shape[1],a.shape[0]),
            (a.astype('b')).tostring())
    return i

# clip the raster only for tg halli area
# http://geospatialpython.com/2011/02/clip-raster-using-shapefile.html 
開發者ID:Kirubaharan,項目名稱:hydrology,代碼行數:13,代碼來源:modis_tg_halli.py


注:本文中的Image.frombytes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。