我有一个看起来像这样的图像,其中有一些较大的杂质/曝光过度的斑点。通常,检测到它们并不重要,因为测量是时间分辨的,因此稍后将其删除。
但是,我对尽可能多的小点感兴趣-尽可能快。skimage.feature.peak_local_max
确实做得很好,并且非常容易在不同数据上使用,因为不需要在强度缩放上花太多时间。
问题是,由于某种原因,大斑点会产生非常强的正面影响。
import skimage.io
import skimage.feature
import skimage.morphology
from matplotlib.collections import PatchCollection
import matplotlib.pyplot as plt
def plotRoi(spots, img_ax, color, radius):
patches = []
for spot in spots:
y, x = spot
c = plt.Circle((x, y), radius)
patches.append(c)
img_ax.add_collection(PatchCollection(patches, facecolors = "None", edgecolors = color, alpha = 0.3, linewidths = 1))
img = skimage.io.imread("/Path/to/img.png")
img = img[:,:,0]
fig, ax = plt.subplots()
ax.imshow(img, cmap = "Greys")
spots = skimage.feature.peak_local_max(img, min_distance = 0, exclude_border = True, num_peaks = 2000)
plotRoi(spots, ax, "red", radius = 10)
plt.show()
在某些图像中搜索数千个斑点会导致大量局部最大值彼此重叠。有没有一种方法可以避免这种情况,例如在图像加载时应用滤镜,因为我不希望转向较慢的峰拟合?
神不在的星期二
相关分类