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


Python Image.show方法代码示例

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


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

示例1: Superpixels

# 需要导入模块: from SimpleCV.ImageClass import Image [as 别名]
# 或者: from SimpleCV.ImageClass.Image import show [as 别名]
class Superpixels(FeatureSet):
    """
    ** SUMMARY **
    Superpixels is a class extended from FeatureSet which is a class
    extended from Python's list. So, it has all the properties of a list
    as well as all the properties of FeatureSet.

    Each object of this list is a Blob corresponding to the superpixel.

    ** EXAMPLE **
    >>> image = Image("lenna")
    >>> sp = image.segmentSuperpixels(300, 20)
    >>> sp.show()
    >>> sp.centers()
    """
    def __init__(self):
        self._drawingImage = None
        self.clusterMeanImage = None
        pass

    def append(self, blob):
        list.append(self, blob)
        #if len(self) != 1:
            #self.image += blob.image.copy()

    @LazyProperty
    def image(self):
        img = None
        for sp in self:
            if img is None:
                img = sp.image
            else:
                img += sp.image
        return img

    def draw(self, color=Color.RED, width=2, alpha=255):
        """
        **SUMMARY**

        Draw all the superpixels, in the given color, to the appropriate layer

        By default, this draws the superpixels boundary. If you
        provide a width, an outline of the exterior and interior contours is drawn.

        **PARAMETERS**

        * *color* -The color to render the blob as a color tuple.
        * *width* - The width of the drawn blob in pixels, if -1 then filled then the polygon is filled.
        * *alpha* - The alpha value of the rendered blob 0=transparent 255=opaque.
        
        **RETURNS**

        Image with superpixels drawn on it.

        **EXAMPLE**

        >>> image = Image("lenna")
        >>> sp = image.segmentSuperpixels(300, 20)
        >>> sp.draw(color=(255, 0, 255), width=5, alpha=128).show()
        """
        img = self.image.copy()
        self._drawingImage = Image(self.image.getEmpty(3))
        _mLayers = []
        for sp in self:
            sp.draw(color=color, width=width, alpha=alpha)
            self._drawingImage += sp.image.copy()
            for layer in sp.image._mLayers:
                _mLayers.append(layer)
        self._drawingImage._mLayers = copy(_mLayers)
        return self._drawingImage.copy()

    def show(self, color=Color.RED, width=2, alpha=255):
        """
        **SUMMARY**

        This function automatically draws the superpixels on the drawing image
        and shows it.

        ** RETURNS **

        None

        ** EXAMPLE **
        >>> image = Image("lenna")
        >>> sp = image.segmentSuperpixels(300, 20)
        >>> sp.show(color=(255, 0, 255), width=5, alpha=128)
        """
        if type(self._drawingImage) == type(None):
            self.draw(color=color, width=width, alpha=alpha)
        self._drawingImage.show()

    def colorWithClusterMeans(self):
        """
        **SUMMARY**

        This function colors each superpixel with its mean color and
        return an image.

        **RETURNS**
        Image with superpixles drawn in its mean color.
#.........这里部分代码省略.........
开发者ID:Betrezen,项目名称:SimpleCV2,代码行数:103,代码来源:Superpixels.py


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