使用OPENCV改善边缘检测

发布于 2025-01-29 01:52:55 字数 651 浏览 1 评论 0原文

因此,我正在研究一个项目来扫描模拟照片。该程序应自动检测边缘和裁剪。为此,我正在使用Python和OpenCV。我的问题是,有时我的程序由于间隙而无法将照片视为整个矩形。这是一个示例:

“示例”

这是我使用Canny的代码台:

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # convert the image to gray scale
blur = cv2.GaussianBlur(gray, (1, 1), 0) # Add Gaussian blur to remove noise
edged = cv2.Canny(blur, 75, 200) # Apply the Canny algorithm to find the edges

我还注意到调整模糊参数仅使其与查找边缘更加不准确。

当照片边界的颜色与表面不同时,该程序似乎起作用。

有什么方法可以改进代码,因此检测照片边缘的更准确性?

so I am working on a project to scan analog photos. The program should detect the edges and crop it automatically. For that I am using Python and OpenCV. My problem is that sometimes my program can not detect the photo as a whole rectangle due to gaps. Here is an example:

example

This is the codepart where I am using canny:

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # convert the image to gray scale
blur = cv2.GaussianBlur(gray, (1, 1), 0) # Add Gaussian blur to remove noise
edged = cv2.Canny(blur, 75, 200) # Apply the Canny algorithm to find the edges

I also noticed that tweaking up the blur parameters only makes it more inaccurate with finding the edges.

The program seems to work when the colour at the border of the photo is different compared to the surface.

Is there any way to improve the code so it is way more accurate in detecting the edges of a photo?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文