赞
踩
没有读取到文件,可能是路径、文件名、后缀错了
参数类型错误或两个参数大小不一致,出现在cv2.bitwise_and()中,可以.dtype, .shape查看
def cvtColor(src, code, dst=None, dstCn=None):
图像类型转换,code=cv2.COLOR_GRAY2BGR灰度图扩充为三通道,RGB2GRAY转灰度图,。。。
- def dilate(src, kernel, dst=None, anchor=None, iterations=None, borderType=None, borderValue=None):
-
- kernel = np.ones((5, 5), np.uint8) # 定义kernel
- gt = cv2.dilate(gt, kernel, iterations=1)
膨胀,可以对二值图像扩充mask
img_erode = cv2.erode(img,None,iterations=5)
侵蚀操作,参考这篇博客
def inpaint(src, inpaintMask, inpaintRadius, flags, dst=None):
填充成和mask周围相近的颜色,可以粗糙的去反光
def illuminationChange(src, mask, dst=None, alpha=None, beta=None):
用一个mask去除反光,mask必须比反光部位大一些,参考这,常用参数alpha=0.4, beta=0.2
- def threshold(src, thresh, maxval, type, dst=None):
- . @param src input array (multiple-channel, 8-bit or 32-bit floating point).
- . @param dst output array of the same size and type and the same number of channels as src.
- . @param thresh threshold value.
- . @param maxval maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding
- . types.
- . @param type thresholding type (see #ThresholdTypes).
- . @return the computed threshold value if Otsu's or Triangle methods used.
获得图像中值高于或低于阈值部分的mask,低于设置type=cv2.THRESH_BINARY_INV
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。