def thresholding(img): # x_thresh = utils.abs_sobel_thresh(img, orient='x', thresh_min=55, thresh_max=100) # mag_thresh = utils.mag_thresh(img, sobel_kernel=3, mag_thresh=(70, 255)) # dir_thresh = utils.dir_threshold(img, sobel_kernel=3, thresh=(0.7, 1.3)) # s_thresh = utils.hls_select(img,channel='s',thresh=(160, 255)) # s_thresh_2 = utils.hls_select(img,channel='s',thresh=(200, 240)) # # white_mask = utils.select_white(img) # yellow_mask = utils.select_yellow(img) x_thresh = utils.abs_sobel_thresh(img, orient='x', thresh_min=10, thresh_max=230) mag_thresh = utils.mag_thresh(img, sobel_kernel=3, mag_thresh=(30, 150)) 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)) #Thresholding combination 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 # threshholded = np.zeros_like(x_thresh) # threshholded[((x_thresh == 1)) | ((mag_thresh == 1) & (dir_thresh == 1))| (white_mask>0)|(s_thresh == 1) ]=1 return threshholded
def thresholding(img): #print(img.shape) #setting all sorts of thresholds #cv2.imshow("orig", img) x_thresh = utils.abs_sobel_thresh(img, orient='x', thresh_min=10, thresh_max=230) #cv2.imshow("x_thresh",x_thresh*255) mag_thresh = utils.mag_thresh(img, sobel_kernel=3, mag_thresh=(30, 150)) #cv2.imshow("mag_thresh",mag_thresh*255) dir_thresh = utils.dir_threshold(img, sobel_kernel=3, thresh=(0.7, 1.3)) #cv2.imshow("dir_thresh",dir_thresh*255) hls_thresh = utils.hls_select(img, thresh=(180, 255)) #cv2.imshow("hls_thresh",hls_thresh*255) lab_thresh = utils.lab_select(img, thresh=(155, 200)) #cv2.imshow("lab_thresh",lab_thresh*255) luv_thresh = utils.luv_select(img, thresh=(225, 255)) #cv2.imshow("luv_thresh",luv_thresh) #Thresholding combination 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 #cv2.imshow("threshholded", threshholded*255) #cv2.waitKey(0) return threshholded
def thresholding(img): x_thresh = utils.abs_sobel_thresh(img, orient='x', thresh_min=10, thresh_max=230) mag_thresh = utils.mag_thresh(img, sobel_kernel=3, mag_thresh=(30, 150)) 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)) #Thresholding combination 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
plt.figure(figsize=(20, 40)) for i in range(0, (len(undistorted_test_images))): plt.subplot(len(undistorted_test_images), 2, 2 * i + 1) plt.title('original image') plt.imshow(test_imgs2[i]) plt.subplot(len(undistorted_test_images), 2, 2 * i + 2) plt.title('after dir_thresh_method') plt.imshow(dir_thresh_method[i], cmap='gray') plt.savefig('dir_thresh_method.png') # In[16]: #lab_thresholding methdods lab_thresh_method = [] for img in test_imgs2: lab_thresh = utils.lab_select(img, thresh=(155, 200)) lab_thresh_method.append(lab_thresh) plt.figure(figsize=(20, 40)) for i in range(0, (len(undistorted_test_images))): plt.subplot(len(undistorted_test_images), 2, 2 * i + 1) plt.title('original image') plt.imshow(test_imgs2[i]) plt.subplot(len(undistorted_test_images), 2, 2 * i + 2) plt.title('after lab_thresh_method') plt.imshow(lab_thresh_method[i], cmap='gray') plt.savefig('lab_thresh_method.png') # In[17]: #luv_thresholding methdods