当前位置: 首页>>代码示例>>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;未经允许,请勿转载。