【问题标题】:Remove small details in image python删除图像python中的小细节
【发布时间】:2021-12-31 06:58:02
【问题描述】:

我已经为这个问题的解决而苦恼了很长时间。我需要去除图像中的多色环和点,但保持密集的形状。我尝试使用 open cv,迭代像素,但我仍然无法摆脱图像中不必要的内容。提前感谢您的建议。

【问题讨论】:

  • 解释(show)这是怎么做到的?
  • 你好。这是通过剪切图像的一部分来完成的。中心被切掉后 - 边缘仍然存在

标签: python computer-vision mask


【解决方案1】:

您可以尝试使用来自OpenCV 的腐蚀/膨胀。 这是一个简单的示例,根据需要编辑参数。

import cv2
import numpy as np

img = cv2.imread('img.png')
blurred_img = cv2.medianBlur(img, 5)

kernel = np.ones((3,3),np.uint8)
erosion = cv2.erode(blurred_img, kernel, iterations=1)
output = cv2.dilate(erosion, kernel, iterations=1)

cv2.imwrite('output.png', output)

【讨论】:

  • 谢谢。确实,open cv 效果很好,但我的做法有点不同,我使用 dilate 更改了原始图像。
猜你喜欢
  • 2016-12-10
  • 1970-01-01
  • 2018-02-07
  • 2020-09-01
  • 2014-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-23
相关资源
最近更新 更多