Digital Image processing Project DRAFT
Project- Tortuous Blood Vessel Detection using DIP
Nitin Kumar
import cv2
import numpy as np
from [Link] import cv2_imshow # Import cv2_imshow for
displaying images in Colab
# Function to apply Gaussian blur and Canny edge detection
def preprocess_image(image):
gray = [Link](image, cv2.COLOR_BGR2GRAY)
blurred = [Link](gray, (5, 5), 0)
edges = [Link](blurred, 50, 150)
return edges
# Function to mask the region of interest
def region_of_interest(image, vertices):
mask = np.zeros_like(image)
[Link](mask, vertices, 255)
masked_image = cv2.bitwise_and(image, mask)
return masked_image
# Function to detect and draw lanes
def detect_lanes(image):
height, width = [Link]
region_of_interest_vertices = [
(0, height),
(width / 2, height / 2),
(width, height),
]
cropped_image = region_of_interest(image,
[Link]([region_of_interest_vertices], np.int32))
lines = [Link](cropped_image, 1, [Link] / 180,
threshold=50, minLineLength=50, maxLineGap=50)
if lines is not None:
for line in lines:
x1, y1, x2, y2 = line[0]
[Link](image, (x1, y1), (x2, y2), (0, 0, 255), 3)
return image
# Read the image or video frame
image = [Link]('/content/FFa-photography-of-both-eyes-showing-
[Link]') # Replace with
your image file path
# Preprocess the image
edges = preprocess_image(image)
# Detect lanes
lane_image = detect_lanes(edges)
# Display the result in Colab
cv2_imshow(lane_image)
Tortuous Blood vessel image given to the code to process.