小编Rex*_*dus的帖子

如何提高表面缺陷的检测能力?

首先,这是我的原始图像,我尝试检测拉丝铝表面上的缺陷(平行线)。 拉丝铝

这是我采取的步骤:

  1. 高斯模糊
  2. 放大图像
  3. 将图像转换为灰度
  4. 变形关闭操作
  5. 再次扩张
  6. 图像的差异
  7. Canny 边缘检测
  8. 寻找轮廓
  9. 在轮廓周围画一条绿线

这是我的代码:

import numpy as np
import cv2
from matplotlib import pyplot as plt
import imutils
path = ''
path_output = ''

img_bgr = cv2.imread(path)
plt.imshow(img_bgr)

# bgr to rgb
img_rgb = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)
plt.imshow(img_rgb)

# Converting to grayscale
img_just_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)

# Displaying the grayscale image
plt.imshow(img_just_gray, cmap='gray')

# Gaussian Blur
ksize_w = 13
ksize_h = 13

img_first_gb = cv2.GaussianBlur(img_rgb, (ksize_w,ksize_h), 0, 0, cv2.BORDER_REPLICATE);
plt.imshow(img_first_gb)

# Dilate …
Run Code Online (Sandbox Code Playgroud)

python opencv

3
推荐指数
1
解决办法
2311
查看次数

标签 统计

opencv ×1

python ×1