我想你有很多选择。我想到的两个简单方法是将输入图像的阈值设置为一个低强度值,这将给你一个白色的圆圈。然后你可以对圆进行Hough变换来找到圆心。在
或者,可以使用阈值白色像素的距离变换,并取此距离变换的最大值:# code derived from watershed example of scikit-image
# http://scikit-image.org/docs/dev/auto_examples/plot_watershed.html
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage as ndi
from skimage.morphology import watershed
from skimage.feature import peak_local_max
from skimage.color import rgb2gray
from skimage.io import imread
img = imread('flame.png')
image = rgb2gray(img) > 0.01
# Now we want to separate the two objects in image
# Generate the markers as local maxima of the distance to the background
distance = ndi.distance_transform_edt(image)
# get global maximum like described in
# http://stackoverflow.com/a/3584260/2156909</