You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于轮廓实现图像平滑边缘裁剪及中心区域关键点提取求助

问题求助:平滑边缘裁剪与中心区域关键点提取

希望通过轮廓实现图像的平滑边缘裁剪,并提取中心区域的关键点,恳请各位提供帮助。

原始图像:
原始图像

我尝试了以下代码:

import cv2 as cv
import numpy as np

img_ref = cv.imread('img.jpeg')
img1 = cv.cvtColor(img_ref, cv.COLOR_BGR2GRAY)
img1_blur = cv.GaussianBlur(img1, (7, 7), cv.BORDER_DEFAULT)

# create mask
thresh, img1_edges1 = cv.threshold(img1_blur, 100, 255, cv.THRESH_BINARY_INV)

# remove noise
img1_edges2 = cv.dilate(img1_edges1, (3, 3), iterations=1)
img1_edges3 = cv.morphologyEx(img1_edges2, cv.MORPH_CLOSE, (7, 7))
mask_img = cv.morphologyEx(img1_edges3, cv.MORPH_OPEN, (7, 7))

# mask the original image
img1_masked = cv.bitwise_and(img_ref, img_ref, mask=mask_img)

# initiate ORB and find the keypoints with SIFT
orb = cv.ORB_create(200)
kp1, des1 = orb.detectAndCompute(img1_masked, None)

img1kp = cv.drawKeypoints(img1_masked, kp1, None, flags=None)

cv.imshow('mask', mask_img)
cv.imshow('key_point', img1kp)
cv.waitKey(0)

但生成的蒙版不干净、边缘不光滑,且提取的关键点全部集中在边缘;我也曾尝试用轮廓制作蒙版,但未能成功。

蒙版结果:
蒙版结果

关键点结果:
关键点结果

提前感谢各位的帮助。

内容的提问来源于stack exchange,提问作者Lala

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 20:25:14