正常图像

有缺陷图像
目的是区分判断出有缺陷的图像。但是,本项目有一些比较困难的点,例如(1),光照或噪声会有变化;(2),有时关键区域位置上会有小的变化
LBP是一种可以解决光照变化和旋转变化的特征向量,是否要用LBP进行特征提取?以下是LBP特征提取的代码:
在图像匹配方面,因为主要观测图像结构的差异,如果是噪声或光照的变化需要忽略,所以我们用到了SSIM来计算图像直接的相似度。
# 以下不再重复这个部分
import cv2
import numpy as np
def origin_LBP(img):
dst = np.zeros(img.shape,dtype=img.dtype)
h,w=img.shape
start_index=1
for i in range(start_index,h-1):
for j in range(start_index,w-1):
center = img[i][j]
code = 0
# 顺时针,左上角开始的8个像素点与中心点比较,大于等于的为1,小于的为0,最后组成8位2进制
code |= (img[i-1][j-1] >= center) << (np.uint8)(7)
code |= (img[i-1][j ] >= center) << (np.uint8)(6)
code |= (img[i-1][j+1] >= center) << (np.uint8)(5)
code |= (img[i ][j+1] >= center) << (np.uint8)(4)
code |= (img[i+1][j+1] >= center) << (np.uint8)(3)
code |= (img[i+1][j ] >= center) << (np.uint8)(2)
code |= (img[i+1][j-1] >= center) << (np.uint8)(1)
code |= (img[i ][j-1] >= center) << (np.uint8)(0)
dst[i-start_index][j-start_index]= code
return dst
def circular_L

本文探讨了在图像处理领域,如何利用局部二值模式(LBP)特征和结构相似度指数(SSIM)来应对光照变化和噪声对图像检测的影响。LBP能够抵抗光照变化,而SSIM则用于衡量图像的结构相似度,从而在有缺陷图像的检测中提供帮助。代码示例展示了LBP的实现及SSIM的计算过程,对于图像匹配和质量评估具有指导意义。
最低0.47元/天 解锁文章
1393

被折叠的 条评论
为什么被折叠?



