<jupyter_start><jupyter_text>LANE DETECTION USING HOUGH TRANSFORMATION  importing modules and the image<jupyter_code>import cv2
import numpy as np
import matplotlib.pyplot as plt
image = cv2.imread("image_lane.jpg")
print(image.shape)
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))<jupyter_output>(540, 960, 3)<jupyter_text>converting the image to gray scale<jupyter_code>image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
print(image_gray.shape)

plt.imshow(image_gray, cmap="gray")<jupyter_output>(540, 960)<jupyter_text>applying gaussian blur<jupyter_code>image_blurred = cv2.GaussianBlur(image_gray, (7,7), 0)
plt.imshow(image_blurred, cmap="gray")<jupyter_output><empty_output><jupyter_text>applying canny edge detection<jupyter_code>low = 100
high = 100
image_canny = cv2.Canny(image_blurred, low, high)
plt.imshow(image_canny, cmap="gray")<jupyter_output><empty_output><jupyter_text>define a region of interest<jupyter_code>vertices = np.array([[(110,550),(400, 350), (530, 350), (820,550)]])
mask = np.zeros_like(image_gray)
cv2.fillPoly(mask, vertices, 255)
masked_image = cv2.bitwise_and(image_canny, mask)
plt.imshow(masked_image, cmap="gray")<jupyter_output><empty_output><jupyter_text>Hough Transformation<jupyter_code>rho = 1            # distance resolution in pixels 
theta = np.pi/180  # angular resolution in radians 
threshold = 200 # minimum number of votes
lines = cv2.HoughLinesP(masked_image, rho, theta, threshold, np.array([]), minLineLength=100, maxLineGap=50)

# Create an empty black image
line_image = np.zeros((masked_image.shape[0], masked_image.shape[1], 3), dtype=np.uint8)

for line in lines:
    for x1,y1,x2,y2 in line:      
        cv2.line(line_image, (x1, y1), (x2, y2), [100, 100, 255], 30)

# Resultant weighted image is calculated as follows: original_img * α + img * β + γ
image_with_lines = cv2.addWeighted(image, 1, line_image, 0.3, 0)

plt.imshow(cv2.cvtColor(image_with_lines, cv2.COLOR_BGR2RGB))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12676767676767678, 'fraction_numerical': 0.05353535353535353, 'mean_word_length': 7.118852459016393, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '234497', 'license': 'MIT', 'n_tokens_mistral': 852, 'n_tokens_neox': 769, 'n_words': 148, 'path': '__init__.ipynb', 'repo_name': 'andreasawires/lane-detection', 'size': '1980'}