def thresholding(img):
x_thresh = utils.abs_sobel_thresh(img, orient='x', thresh_min=180 ,thresh_max=255)
mag_thresh = utils.mag_thresh(img, sobel_kernel=3, mag_thresh=(50, 100))
dir_thresh = utils.dir_threshold(img, sobel_kernel=3, thresh=(0.7, 1.3))
hls_thresh = utils.hls_select(img, thresh=(180, 255))
lab_thresh = utils.lab_select(img, thresh=(155, 200))
luv_thresh = utils.luv_select(img, thresh=(225, 255))
threshholded = np.zeros_like(x_thresh)
threshholded[((x_thresh == 1) & (mag_thresh == 1)) |
((dir_thresh == 1) & (hls_thresh == 1)) |
(lab_thresh == 1) |
(luv_thresh == 1)] = 1
return threshholded
例如这里的threshholded代码块,这里读出来的图片格式为布尔类型,最后的融合部分转换成为了数值1,0类型,但是直接imshow出来的图片使黑图,无效果,这里就使格式问题了。
下面上代码,终极解决办法
import matplotlib.pyplot as plt
plt.imshow(img)
plt.show()
改用后便可以读出图片了,百试百灵