本文整理汇总了Python中SimpleCV.ImageClass.Image.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Image.copy方法的具体用法?Python Image.copy怎么用?Python Image.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleCV.ImageClass.Image
的用法示例。
在下文中一共展示了Image.copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Superpixels
# 需要导入模块: from SimpleCV.ImageClass import Image [as 别名]
# 或者: from SimpleCV.ImageClass.Image import copy [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.
#.........这里部分代码省略.........