本文整理汇总了Python中cluster.Cluster.find_centroid方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.find_centroid方法的具体用法?Python Cluster.find_centroid怎么用?Python Cluster.find_centroid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.find_centroid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_cluster_array
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import find_centroid [as 别名]
def get_cluster_array(pixels, background, dispersion, threshold=None, my_wcs=None):
"""
Find the list of clusters in the picture pixels
according to a threshold defines with background and dispersion
:param pixels: 2D array corresponding to the picture
:param background: mean background value
:param dispersion: dispersion of the background
:return: list of clusters found in the picture pixels
"""
# Initiate some variables before looping over all pixels
if threshold is None:
threshold = background + 6.0 * dispersion # threshold value
marks = np.zeros(pixels.shape) # to mark each pixels
n_row, n_column = pixels.shape
cluster_array = [] # will contain instances of the class Cluster
# Loop over pixels and add clusters in cluster_array
for i in range(n_row):
for j in range(n_column):
if marks[i][j] != 1: # if the pixel is not marked
marks[i][j] = 1 # mark it
if pixels[i][j] >= threshold: # if luminosity > threshold
clust = Cluster()
clust.recursive_exploration(i, j, pixels, marks, threshold)
if my_wcs != None:
clust.find_centroid(my_wcs=my_wcs)
else:
clust.find_centroid()
cluster_array.append(clust)
# Return the array of clusters
return cluster_array