模糊python中的图像边缘

发布于 2025-02-12 00:36:27 字数 700 浏览 0 评论 0原文

我正在尝试阅读二进制RGB图像,并只是模糊边缘。这是我现在的非工作代码。我遇到了这个错误:“ ValueError:操作数无法与形状(2048,2048,3)(2048,2048)一起广播

import cv2
import numpy as np
import skimage.exposure
import matplotlib.pyplot as plt

# load image
img = cv2.imread('mask.png')


# Get edges
edges = cv2.Canny(image=img.astype(np.uint8), threshold1=100, threshold2=200) # Canny Edge Detection

#Remove edges from image
img = img - edges

# Blur
blur = cv2.GaussianBlur(edges, (0,0), sigmaX=2.5, sigmaY=2.5, borderType = cv2.BORDER_DEFAULT)

img = img + blur

# save output
cv2.imwrite('bw_image_antialiased.png', img)

。更快,更高效?

“

I'm trying to read a binary RGB image and blur just the edges. This is my non-working code upto now. I get this error: "ValueError: operands could not be broadcast together with shapes (2048,2048,3) (2048,2048)"

import cv2
import numpy as np
import skimage.exposure
import matplotlib.pyplot as plt

# load image
img = cv2.imread('mask.png')


# Get edges
edges = cv2.Canny(image=img.astype(np.uint8), threshold1=100, threshold2=200) # Canny Edge Detection

#Remove edges from image
img = img - edges

# Blur
blur = cv2.GaussianBlur(edges, (0,0), sigmaX=2.5, sigmaY=2.5, borderType = cv2.BORDER_DEFAULT)

img = img + blur

# save output
cv2.imwrite('bw_image_antialiased.png', img)

Is there a better way to do this? Faster, more efficient?

The images

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

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

发布评论

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