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


Python Image.histogram方法代码示例

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


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

示例1: classify

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import histogram [as 别名]
def classify(im, K, show=False):
    """ classify    - classify an image using k-means algorithm.

    Arguments:
        * im            - an image (ndarray) or a filename.
        * K             - number of classes.
        * show  = False - if True, display the image and the classes.

    Return:
        * imClasses     - the classes of the image (ndarray, 2D).

    See also:
        * kMeans        - K-means algorithm.
    """
    a = Image(im)
    a = a.histogram(255)
    
    # Load image
    if type(im) is str:
        im = plt.imread(im)

    # Reshape and apply k-mean
    values = im.reshape((im.shape[0] * im.shape[1], -1))
    centers, classes = kMeans(values, K)
    imClasses = classes.reshape((im.shape[0], im.shape[1]))
##    imClasses.save("imClassesH.png")
##    imClassesHl=image("imClassesH.png")
##    imClassHisto=imClassesH1.histogram(255)
    
    
    # Display
    if show:
                
        cmap = 'gray' if im.ndim < 3 else None
        plt.subplot(131), plt.imshow(im, cmap=cmap), plt.title('Imagen Gray')
        plt.subplot(132), plt.imshow(imClasses), plt.title('Segmentacion por Clases')
        pylab.subplot(133), pylab.plot(a), pylab.draw(), pylab.pause(0.0001), pylab.title('Histograma Img Gray')

        plt.show()

    # The end
    return imClasses
开发者ID:Wenarepo,项目名称:HOLArepo,代码行数:44,代码来源:004SEGMENTATOR.py

示例2: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import histogram [as 别名]
from SimpleCV import Image

# change this to process multiple images
img = Image("../images/beach.jpeg")
histogram = img.histogram()

print histogram.getFieldNames
开发者ID:cameronaverill,项目名称:SongSlideshow,代码行数:9,代码来源:colorHistogramProcessor.py

示例3: Exception

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import histogram [as 别名]
        * X     - center of the classes, row by row (ndarray, 2D).

    See also:
        * kMeans            - k-means classification.
        * nearestNeighbor   - nearest neighbor classification.
    """

    # Check dimensions
    if Y.ndim != 2:
        raise Exception('data matrix must be a 2D ndarray')
    if C.ndim != 1:
        raise Exception('classes matrix must be a 1D ndarray')
    if Y.shape[0] != C.shape[0]:
        raise Exception('Y and C matrix must have the same number of rows')

    # Create an empty array
    K = C.max() + 1
    X = np.ndarray((K, Y.shape[1]), Y.dtype)

    # Compute barycenters
    for k in range(K):
        X[k,:] = Y[C == k,:].mean(0)

    # Return them
    return X

a = Image("hola5Gray.png")
b = a.histogram(255)

classify("hola5Gray.png", 2, show=True)
开发者ID:Wenarepo,项目名称:HOLArepo,代码行数:32,代码来源:004SEGMENTATOR.py

示例4: getHistogram

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import histogram [as 别名]
def getHistogram(imageFile):
    im = Image(imageFile)
    #im = im.toRGB()
    im = im.toHSV()
    
    return im.histogram(64)
开发者ID:chermong21,项目名称:ImageSea,代码行数:8,代码来源:retrieve.py

示例5: Image

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import histogram [as 别名]
from SimpleCV import Image
from SimpleCV.Shell import plot

img = Image('ex21a.jpg') # Open ex21b.jpg and ex21c.jpg too :)

# Generate the histogram with 256 bins, one for each color
histogram = img.histogram(256)
# Show how many elements are in the list
len(histogram)
# Graphically display the histogram
plot(histogram)
开发者ID:italofernandes84,项目名称:Python-SimpleCV_Course_Examples,代码行数:13,代码来源:ex21.py

示例6: Camera

# 需要导入模块: from SimpleCV import Image [as 别名]
# 或者: from SimpleCV.Image import histogram [as 别名]
#!/usr/bin/python

from SimpleCV import Camera, Display, Image
import matplotlib.pyplot as plt
import time

cam = Camera()
img = cam.getImage().save("img.jpg")
img = Image("img.jpg")
img.show()
imgGray = img.grayscale().save("imgGray.jpg")
imgGray = Image("imgGray.jpg")
imgGray.show()
hist = imgGray.histogram(255)

(red, green, blue) = img.splitChannels(False)
red_histogram = red.histogram(255)
green_histogram = green.histogram(255)
blue_histogram = blue.histogram(255)
plt.figure(1)
plt.subplot(411)
plt.plot(hist)
plt.subplot(412)
plt.plot(red_histogram)
plt.subplot(413)
plt.plot(green_histogram)
plt.subplot(414)
plt.plot(blue_histogram)
plt.show()

print("Ingresar parametro para binarizar: ")
开发者ID:Grupopdicyf,项目名称:PDI_2016,代码行数:33,代码来源:Lab2PDI.py


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