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


Python cm.hsv方法代码示例

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


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

示例1: draw

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import hsv [as 别名]
def draw(self, dbscan_input_array, dbscan_label, dbscan_label_n):

        # convert array to image
        frame_draw = np.zeros((self.__compress_height, self.__compress_width), np.uint8)
        frame_draw = cv2.cvtColor(frame_draw, cv2.COLOR_GRAY2RGB)
        for i in range(dbscan_input_array.shape[0]):
            if not dbscan_label[i] == -1:
                color_th = dbscan_label[i] / dbscan_label_n
                c_r = int(cm.hsv(color_th)[0]*255)
                c_g = int(cm.hsv(color_th)[1]*255)
                c_b = int(cm.hsv(color_th)[2]*255)
                frame_draw = cv2.circle(frame_draw, \
                                        (int(dbscan_input_array[i][0]), \
                                         int(dbscan_input_array[i][1])), \
                                        1, (c_r, c_g, c_b), 1)

        return frame_draw 
开发者ID:YanbaruRobotics,项目名称:PythonPilot,代码行数:19,代码来源:dbscan_based.py

示例2: hsv

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import hsv [as 别名]
def hsv():
    '''
    set the default colormap to hsv and apply to current image if any.
    See help(colormaps) for more information
    '''
    rc('image', cmap='hsv')
    im = gci()

    if im is not None:
        im.set_cmap(cm.hsv)
    draw_if_interactive()


# This function was autogenerated by boilerplate.py.  Do not edit as
# changes will be lost 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:pyplot.py

示例3: plot_2d_clusters

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import hsv [as 别名]
def plot_2d_clusters(X, labels, centers):
    """
    Given an observation array, a label vector, and the location of the centers
    plot the clusters
    """

    clabels = set(labels)
    K = len(clabels)

    if len(centers) != K:
        raise ValueError("Expecting the number of unique labels and centres to"
                         " be the same!")

    # Plot the true clusters
    figure(figsize=(10, 10))
    ax = gca()

    vor = Voronoi(centers)

    voronoi_plot_2d(vor, ax)

    colors = cm.hsv(np.arange(K)/float(K))
    for k, col in enumerate(colors):
        my_members = labels == k
        scatter(X[my_members, 0], X[my_members, 1], c=col, marker='o', s=20)

    for k, col in enumerate(colors):
        cluster_center = centers[k]
        scatter(cluster_center[0], cluster_center[1], c=col, marker='o', s=200)

    axis('tight')
    axis('equal')
    title('Clusters') 
开发者ID:NICTA,项目名称:MLSS,代码行数:35,代码来源:tututils.py

示例4: plot_2d_GMMs

# 需要导入模块: from matplotlib import cm [as 别名]
# 或者: from matplotlib.cm import hsv [as 别名]
def plot_2d_GMMs(X, labels, means, covs, percentcontour=0.66, npoints=30):
    """
    Given an observation array, a label vector (integer values), and GMM mean
    and covariance parameters, plot the clusters and parameters.
    """

    clabels = set(labels)
    K = len(clabels)

    if len(means) != len(covs) != K:
        raise ValueError("Expecting the number of unique labels, means and"
                         "covariances to be the same!")

    phi = np.linspace(-np.pi, np.pi, npoints)

    circle = np.array([np.sin(phi), np.cos(phi)]).T

    figure(figsize=(10, 10))
    gca()

    colors = cm.hsv(np.arange(K)/float(K))
    for k, col in zip(clabels, colors):

        # points
        my_members = labels == k
        scatter(X[my_members, 0], X[my_members, 1], c=col, marker='o', s=20)

        # means
        cluster_center = means[k, :]
        scatter(cluster_center[0], cluster_center[1], c=col, marker='o', s=200)

        # covariance
        L = la.cholesky(np.array(covs[k]) * chi2.ppf(percentcontour, [3])
                        + 1e-5 * np.eye(covs[k].shape[0]))
        covpoints = circle.dot(L) + means[k, :]
        plot(covpoints[:, 0], covpoints[:, 1], color=col, linewidth=3)

    axis('tight')
    axis('equal')
    title('Clusters') 
开发者ID:NICTA,项目名称:MLSS,代码行数:42,代码来源:tututils.py


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