0% found this document useful (0 votes)
21 views24 pages

22am602 Lab Manual

The document outlines the curriculum for the Computer Vision and Digital Imaging Laboratory course under the Department of Artificial Intelligence and Machine Learning, set for release in 2025. It includes course outcomes, program outcomes, and specific experiments designed to enhance skills in AI and machine learning applications, such as image analysis and noise removal. The document also details the objectives, materials, procedures, and expected results for various experiments using Python programming.

Uploaded by

SUSEELA D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views24 pages

22am602 Lab Manual

The document outlines the curriculum for the Computer Vision and Digital Imaging Laboratory course under the Department of Artificial Intelligence and Machine Learning, set for release in 2025. It includes course outcomes, program outcomes, and specific experiments designed to enhance skills in AI and machine learning applications, such as image analysis and noise removal. The document also details the objectives, materials, procedures, and expected results for various experiments using Python programming.

Uploaded by

SUSEELA D
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND MACHINE

LEARNING

22AM602

COMPUTER VISION AND DIGITAL IMAGING LABORATORY

S6 (AIML)

Year of Release 2025 (EVEN)


DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND MACHINE
LEARNING

22AM602

COMPUTER VISION AND DIGITAL IMAGING LABORATORY

S6 (AIML)

Prepared by Approved by
Dr.Rajasekar S S, AP/AIML Dr.A.Kodieswari, Head/AIML

Ms.Karthika S, AP/AIML

Year of Release 2025


COs, POs and PSOs
Course Outcomes (COs)
CO1: Analyse the fundamental concepts of artificial intelligence
CO2: Impart the different paradigms in knowledge representation and reasoning
CO3: Determine the problems to solve using artificial intelligence and machine learning

Program Outcomes (POs)


PO1: Engineering Knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
PO2: Problem Analysis: Identify, formulate, review research literature, and analyse
complex engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
PO3: Design/ Development of Solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.
PO4: Conduct Investigations of Complex Problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.
PO5: Modern Tool Usage: Create, select, and apply appropriate techniques, resources,
and modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.

Program Specific Outcomes (PSOs)


PSO 1: Develop models in Data Science, Machine learning, deep learning and Big data
technologies, using AI and modern tools.

PSO 2: Formulate solutions for interdisciplinary AI problems through acquired


programming knowledge in the respective domains fulfilling with real-time constraints.
Department Vision:
To achieve excellence in the field of Artificial Intelligence and Machine Learning by focusing
on knowledge-centric education systems, integrative partnerships, innovation and cutting-
edge research to meet latest industry standards and service the greater cause of society.
Department Mission:
I. To develop professionals skilled in the field of Artificial Intelligence and Machine
Learning.
II. To impart quality and value based education and contribute towards the innovation of
computing, expert systems, AI, ML to solve complex problems in research and society.
List of Experiments
S. No. Name of the Experiment Page No.
Design and implement a system to analyze images captured by 1
1 surveillance cameras to detect and label objects with specific
shapes for security purposes.
2 Design and implement Automated Image Noise Removal for 5
Medical Imaging.
3 Design an app for Automated Shape Validation through Edge 9
and Corner Detection.
4 Design a lane detection system using perspective projection 15
to improve road navigation.
Detect the corners of an object using corner detection algorithm. 21
5 Design a home automation system where users can control smart
home devices like lights, fans, or appliances using hand gestures.
Design the system that Classify the vehicles on the road and count 29
6 the number of vehicles that travel through a road using the Faster
R-CNN algorithm.
1
22AM602 – Computer Vision and Digital Imaging Laboratory

DESIGN AND IMPLEMENT A SYSTEM TO ANALYZE IMAGES CAPTURED BY


SURVEILLANCE CAMERAS TO DETECT AND LABEL OBJECTS WITH
SPECIFIC SHAPES FOR SECURITY PURPOSES

Exp. No. : 1

AIM/OBJECTIVE:

To implement a system to analyze images captured by surveillance cameras to detect and


label objects with specific shapes for security purposes using python program.

MATERIALS REQUIRED/SOFTWARE REQUIRED:


 Python
 Online compiler

PROCEDURE:

1. Converts the image to grayscale and applies Gaussian blur.


2. Uses the Canny edge detector to highlight object boundaries.
3. Identifies triangles, rectangles, squares, and circles by analyzing contours.
4. Draws the detected shapes and labels them.
5. Displays the processed image and saves it.

PROGRAM:

import cv2
import numpy as np
def detect_shapes(image_path):
image = cv2.imread(image_path)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
edges = cv2.Canny(blurred, 50, 150)
contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
epsilon = 0.04 * cv2.arcLength(contour, True)
3
22AM602 – Computer Vision and Digital Imaging Laboratory
approx = cv2.approxPolyDP(contour, epsilon, True)
x, y, w, h = cv2.boundingRect(approx)
shape_name = "Unknown"
if len(approx) == 3:
shape_name = "Triangle"
elif len(approx) == 4:
aspect_ratio = float(w) / h
shape_name = "Square" if 0.9 <= aspect_ratio <= 1.1 else "Rectangle"
elif len(approx) > 4:
shape_name = "Circle"
cv2.drawContours(image, [approx], -1, (0, 255, 0), 2)
cv2.putText(image, shape_name, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0,
255), 2)
cv2.imshow('Detected Shapes', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imwrite('output_detected_shapes.jpg', image)
detect_shapes('surveillance_image.jpg')
OUTPUT:

RESULT:

Thus implementing a system to analyze images captured by surveillance cameras to detect


and label objects with specific shapes for security purposes using Python program was executed and
output was verified successfully.

CO No PO1 PO2 PO3 PSO1


1 2 2 3 2
5
22AM602 – Computer Vision and Digital Imaging Laboratory

DESIGN AND IMPLEMENT AUTOMATED IMAGE NOISE REMOVAL FOR MEDICAL


IMAGING

Exp. No. : 2

AIM/ OBJECTIVE
To design and implement Automated Image Noise Removal for Medical Imaging using
Python program.

MATERIALS REQUIRED/SOFTWARE REQUIRED:

 Python
 Online compiler

PROCEDURE:

1. Loads a grayscale medical image.


2. Applies Gaussian Blur for smoothing.
3. Applies Median Blur to remove salt-and-pepper noise.
4. Uses Non-Local Means Denoising for high-quality denoising.
5. Displays original and processed images for comparison.
6. Saves the final denoised image as denoised_medical_image.jpg.

PROGRAM:
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('bear.png')
dst = cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 15)
plt.subplot(121), plt.imshow(img)
plt.subplot(122), plt.imshow(dst)
plt.show()
7

22AM602 – Computer Vision and Digital Imaging Laboratory

OUTPUT:

RESULT:

Thus designing and implementing Automated Image Noise Removal for Medical Imaging
using Python program was executed and output was verified successfully.

MAPPING OF PO & PSO:

CO No PO1 PO3 PO4 PSO1


2 2 2 3 2
9
22AM602 – Computer Vision and Digital Imaging Laboratory

DESIGN AN APP FOR AUTOMATED SHAPE VALIDATION THROUGH EDGE AND


CORNER DETECTION.

Exp. No. : 3

AIM/OBJECTIVE:

To design an app for Automated Shape Validation through Edge and Corner Detection using
Python program

MATERIALS REQUIRED/SOFTWARE REQUIRED:

 Python
 Online compiler
PROCEDURE:

1. Ensures a number can be placed in a row, column, and 3×3 subgrid.


2. Uses a backtracking algorithm with randomized numbers to fill the board.
3. Removes numbers to create a valid puzzle while keeping it solvable.
4. Generates a full board and then removes numbers based on difficulty.
5. Prints the puzzle and solution in a readable format.
PROGRAM:

# Python program to illustrate


# corner detection with
# Harris Corner Detection Method
# organizing imports
import cv2
import numpy as np
# path to input image specified and
# image is loaded with imread command
image = cv2.imread('GeekforGeeks.jpg')
# convert the input image into
# grayscale color space
operatedImage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
11

22AM602 – Computer Vision and Digital Imaging Laboratory

# modify the data type


# setting to 32-bit floating point
operatedImage = np.float32(operatedImage)
# apply the cv2.cornerHarris method
# to detect the corners with appropriate
# values as input parameters
dest = cv2.cornerHarris(operatedImage, 2, 5, 0.07)
# Results are marked through the dilated corners
dest = cv2.dilate(dest, None)
# Reverting back to the original image,
# with optimal threshold value
image[dest > 0.01 * dest.max()]=[0, 0, 255]
# the window showing output image with corners
cv2.imshow('Image with Borders', image)
# De-allocate any associated memory usage
if cv2.waitKey(0) & 0xff == 27:
cv2.destroyAllWindows()

OUTPUT:
13

22AM602 – Computer Vision and Digital Imaging Laboratory

RESULT:

Thus designing an app for Automated Shape Validation through Edge and Corner Detection using
Python program using python program was executed and output was verified successfully.

MAPPING OF PO & PSO:

CO No PO1 PO2 PO5 PSO2


3 2 2 3 1
15

22AM602 – Computer Vision and Digital Imaging Laboratory

DESIGN A LANE DETECTION SYSTEM USING PERSPECTIVE PROJECTION TO


IMPROVE ROAD NAVIGATION
Exp. No.: 4
Date :

AIM/OBJECTIVE:

To design a lane detection system using perspective projection to improve road navigation
using python program.
MATERIALS REQUIRED/SOFTWARE REQUIRED:

 Python
 Online compiler
PROCEDURE:

1. Capture Image/Video (from a camera or file).


2. Apply Perspective Transformation to get a top-down view.
3. Detect Edges using Canny Edge Detection.
4. Detect Lane Lines using Hough Line Transform.
5. Overlay the detected lanes on the original image.

PROGRAM:

import cv2
import numpy as np
import matplotlib.pyplot as plt
def perspective_transform(image):
"""
Apply a perspective transformation to get a bird's-eye view of the road.
"""
height, width = image.shape[:2]
src_points = np.float32([
[width * 0.45, height * 0.65], # Bottom-left
[width * 0.55, height * 0.65], # Bottom-right
[width * 0.85, height * 0.90], # Top-right
[width * 0.15, height * 0.90] # Top-left
])
17

22AM602 – Computer Vision and Digital Imaging Laboratory

dst_points = np.float32([
[width * 0.2, 0], # New Bottom-left
[width * 0.8, 0], # New Bottom-right
[width * 0.8, height], # New Top-right
[width * 0.2, height] # New Top-left
])
matrix = cv2.getPerspectiveTransform(src_points, dst_points)
transformed = cv2.warpPerspective(image, matrix, (width, height))
return transformed
def detect_edges(image):
"""
Apply Canny edge detection to extract lane edges.
"""
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
edges = cv2.Canny(blurred, 50, 150)
return edges
def detect_lanes(image):
"""
Detect lane lines using Hough Transform.
"""
edges = detect_edges(image)
lines = cv2.HoughLinesP(edges, 1, np.pi/180, 50, minLineLength=50, maxLineGap=150)
lane_image = np.zeros_like(image)
if lines is not None:
for line in lines:
x1, y1, x2, y2 = line[0]
cv2.line(lane_image, (x1, y1), (x2, y2), (0, 255, 0), 5)
lane_overlay = cv2.addWeighted(image, 0.8, lane_image, 1, 1)
return lane_overlay
image = cv2.imread('road_image.jpg')
if image is None:
print("Error: Image not found!")
exit()
19

22AM602 – Computer Vision and Digital Imaging Laboratory

bird_eye_view = perspective_transform(image)
lane_detected = detect_lanes(bird_eye_view)
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
titles = ['Original Image', 'Bird-Eye View (Transformed)', 'Lane Detection']
images = [image, bird_eye_view, lane_detected]
for ax, img, title in zip(axes, images, titles):
ax.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
ax.set_title(title)
ax.axis('off')
plt.show()
cv2.imwrite('bird_eye_view.jpg', bird_eye_view)
cv2.imwrite('lane_detected.jpg', lane_detected)
print("Lane detection completed! Images saved as 'bird_eye_view.jpg' and 'lane_detected.jpg'")

OUTPUT:

RESULT:
Thus design a lane detection system using perspective projection to improve road navigation
using python program was executed and output was verified successfully.

MAPPING OF PO & PSO:

CO No PO1 PO2 PO3 PSO1


4 2 2 3 2
21
22AM602 – Computer Vision and Digital Imaging Laboratory

DETECT THE CORNERS OF AN OBJECT USING CORNER DETECTION ALGORITHM.


DESIGN A HOME AUTOMATION SYSTEM WHERE USERS CAN CONTROL SMART
HOME DEVICES LIKE LIGHTS, FANS, OR APPLIANCES USING HAND GESTURES

Exp. No.: 5

AIM/OBJECTIVE:

To detect the corners of an object using corner detection algorithm. Design a home automation
system where users can control smart home devices like lights, fans, or appliances using hand
gestures using python program.

MATERIALS REQUIRED/SOFTWARE REQUIRED:

 Python
 Online compiler
PROCEDURE:

1. Detect Hand Gesture using a webcam.


2. Use Corner Detection (Harris Detector) to find finger tips or hand edges.
3. Recognize Specific Gestures (e.g., open palm for turning on lights, closed fist for turning off).
4. Send Control Commands to a simulated smart home system (using print statements or actual
IoT integration).

PROCEDURE:

import cv2

import numpy as np
import mediapipe as mp

mp_hands = mp.solutions.hands
mp_draw = mp.solutions.drawing_utils
hands = mp_hands.Hands(min_detection_confidence=0.7, min_tracking_confidence=0.7)
cap = cv2.VideoCapture(0)
def detect_corners(image):

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


23

22AM602 – Computer Vision and Digital Imaging Laboratory

gray = np.float32(gray)

corners = cv2.cornerHarris(gray, 2, 3, 0.04)


corners = cv2.dilate(corners, None)
image[corners > 0.01 * corners.max()] = [0, 0, 255] # Mark corners in red
return image
def recognize_gesture(landmarks):

thumb_up = landmarks[4].y < landmarks[3].y


fingers_extended = sum([landmarks[i].y < landmarks[i - 2].y for i in [8, 12, 16, 20]])
if thumb_up and fingers_extended == 4:
return "Lights ON"
elif not thumb_up and fingers_extended == 0:
return "Lights OFF"
elif fingers_extended == 2:
return "Fan ON"
elif fingers_extended == 3:
return "Fan OFF"

else:
return "No Action"
while cap.isOpened():
ret, frame = cap.read()
if not ret:

break
frame = cv2.flip(frame, 1)
rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
results = hands.process(rgb_frame)
if results.multi_hand_landmarks:

for hand_landmarks in results.multi_hand_landmarks:


mp_draw.draw_landmarks(frame, hand_landmarks, mp_hands.HAND_CONNECTIONS)
25
22AM602 – Computer Vision and Digital Imaging Laboratory

gesture = recognize_gesture(hand_landmarks.landmark)
cv2.putText(frame, f"Action: {gesture}", (10, 50), cv2.FONT_HERSHEY_SIMPLEX, 1,
(0, 255, 0), 2)
if gesture == "Lights ON":
print("Turning Lights ON")

elif gesture == "Lights OFF":


print("Turning Lights OFF")

elif gesture == "Fan ON":


print("Turning Fan ON")
elif gesture == "Fan OFF":
print("Turning Fan OFF")
frame = detect_corners(frame)
cv2.imshow("Hand Gesture Control", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):

break
cap.release()

cv2.destroyAllWindows()

OUTPUT:

RESULT:
Thus detecting the corners of an object using corner detection algorithm. Design a home
automation system where users can control smart home devices like lights, fans, or appliances using
hand gestures using python program was executed and output was verified successfully.
27

22AM602 – Computer Vision and Digital Imaging Laboratory

MAPPING OF PO & PSO:

CO No PO1 PO2 PO3 PSO1 PSO2


5 2 2 3 2 2
29

22AM602 – Computer Vision and Digital Imaging Laboratory

DESIGN THE SYSTEM THAT CLASSIFY THE VEHICLES ON THE ROAD AND
COUNT THE NUMBER OF VEHICLES THAT TRAVEL THROUGH A ROAD USING
THE FASTER R-CNN ALGORITHM.

Exp. No. : 6

AIM/OBJECTIVE:

To design the system that Classify the vehicles on the road and count the number of vehicles
that travel through a road using the Faster R-CNN algorithm in python program.

MATERIALS REQUIRED/SOFTWARE REQUIRED:

 Python
 Online compiler

PROCEDURE:

1. Loads a Road Image (road_image.jpg).


2. Detects Vehicles (cars, trucks, buses, motorcycles) using Faster R-CNN.
3. Draws Bounding Boxes around detected vehicles.
4. Counts the Number of Vehicles on the road.
5. Displays the Output Image with detected vehicles and labels.
6. Saves the Output Image (detected_vehicles.jpg).

PROGRAM:

import cv2

import torch

import torchvision

from torchvision import transforms

import numpy as np

import matplotlib.pyplot as plt


31

22AM602 – Computer Vision and Digital Imaging Laboratory

# Load the pre-trained Faster R-CNN model

model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)

model.eval()

# Define COCO dataset class labels (Faster R-CNN is trained on COCO dataset)

COCO_LABELS = [

' background ', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',

'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign',

'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',

'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag',

'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite',

'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket',

'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana',

'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza',

'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table',

'toilet', 'TV', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',

'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock',

'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'

# Function to detect and count vehicles

def detect_vehicles(image):

transform = transforms.Compose([transforms.ToTensor()])

image_tensor = transform(image).unsqueeze(0)

with torch.no_grad():

predictions = model(image_tensor)
33

22AM602 – Computer Vision and Digital Imaging Laboratory

# Extract results

boxes = predictions[0]['boxes'].cpu().numpy()

labels = predictions[0]['labels'].cpu().numpy()

scores = predictions[0]['scores'].cpu().numpy()

# Filter detections based on confidence threshold

confidence_threshold = 0.6

filtered_boxes = []

vehicle_count = 0

detected_vehicles = []

for i in range(len(scores)):

if scores[i] > confidence_threshold and COCO_LABELS[labels[i]] in ['car', 'bus', 'truck',


'motorcycle']:

vehicle_count += 1

filtered_boxes.append(boxes[i])

detected_vehicles.append(COCO_LABELS[labels[i]])

return filtered_boxes, detected_vehicles, vehicle_count

# Load an example road image

image_path = 'road_image.jpg' # Change this to your road image

image = cv2.imread(image_path)

if image is None:

print("Error: Image not found!")

exit()

# Convert image from BGR to RGB for correct display

image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

# Detect vehicles in the image


35

22AM602 – Computer Vision and Digital Imaging Laboratory

boxes, vehicles, count = detect_vehicles(image_rgb)

# Draw bounding boxes and labels on the image

for i, box in enumerate(boxes):

x1, y1, x2, y2 = map(int, box)

label = vehicles[i]

cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 3)

cv2.putText(image, f"{label}", (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0),


2)

# Display results

plt.figure(figsize=(10, 5))

plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))

plt.title(f"Detected Vehicles: {count}")

plt.axis('off')

plt.show()

# Save output image

cv2.imwrite("detected_vehicles.jpg", image)

print(f"Vehicle Detection Completed! {count} vehicles detected. Image saved as


'detected_vehicles.jpg'.")

OUTPUT:
37

22AM602 – Computer Vision and Digital Imaging Laboratory

RESULT:

Thus develop a program for predicting Student Course Success Based on Attendance and
Participation using Bayesian Belief Network in python program was executed and output was verified
successfully.

MAPPING OF PO & PSO:

CO No PO1 PO2 PO3 PSO1


5 2 2 3 2

You might also like