gpt4 book ai didi

python - 点检测和圆区域选择

转载 作者:太空狗 更新时间:2023-10-30 02:30:58 24 4
gpt4 key购买 nike

我正在处理特定类型的图像。那些,在获得频谱(应用 fft)后,我获得了以下图片:

enter image description here

所以我想通过以下方式选择其中一个“点”(称为谱阶):

enter image description here

我的意思是在它周围“画”一个圆圈,选择里面的像素,然后将这些像素居中(没有“边框圆圈”):

enter image description here

如何使用 OpenCV 执行它?是否存在任何函数?

最佳答案

编辑:根据下面的讨论,要“选择”一个圆圈,可以使用 mask :

# Build mask
mask = np.zeros(image_array.shape, dtype=np.uint8)
cv2.circle(mask, max_loc, circle_radius, (255, 255, 255), -1, 8, 0)

# Apply mask (using bitwise & operator)
result_array = image_array & mask

# Crop/center result (assuming max_loc is of the form (x, y))
result_array = result_array[max_loc[1] - circle_radius:max_loc[1] + circle_radius,
max_loc[0] - circle_radius:max_loc[0] + circle_radius, :]

这给我留下了类似的东西:

Masked and cropped image

另一个编辑: This可能对查找峰值有用。

关于python - 点检测和圆区域选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24267558/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com