Lecture 3 AI Summary
Lecture 3 AI Summary
import numpy as np
plt.figure(figsize=(10, 10))
plt.show()
import cv2
import numpy as np
# Plot results
plt.figure(figsize=(15, 5))
plt.show()
Challenges: Noise
Solutions include:
import numpy as np
# Plot results
plt.figure(figsize=(15, 5))
plt.show()
Susceptible to noise: Increasing Gaussian smoothing (σ) can help reduce spurious
edges.
No edge orientation: Unlike Sobel or Prewitt, LoG does not indicate the direction of
edges.
Comparison: DoG vs. LoG
import numpy as np
sigma = 1.0
# Plot results
plt.figure(figsize=(15, 5))
plt.show()
Advantages of LoG
import numpy as np
sigma = 1.0
# Plot results
plt.figure(figsize=(10, 5))
plt.show()
import cv2
import numpy as np
# Display results
plt.figure(figsize=(15, 5))
plt.show()
3. Scale-Space Representation
Gaussian filters are widely used in real-world scenarios across various domains due to their
simplicity and effectiveness. Let’s explore some key applications:
1. Image Preprocessing
Gaussian filters are a common first step in processing images for further analysis.
Applications:
Medical Imaging: Reduce noise in X-rays, MRIs, and CT scans to improve clarity and
enhance diagnostic accuracy.
Object Detection: Smooth images before detecting objects to minimize false
positives caused by noise.
Example:
In self-driving cars, Gaussian filters preprocess camera feeds to ensure reliable detection of
road signs and obstacles.
2. Edge Detection
Gaussian filters help refine the results of edge detection algorithms like Sobel, Prewitt, and
Canny by reducing noise.
Applications:
Traffic Monitoring: Detect lane markers and vehicle edges in video streams.
Canny uses a Gaussian filter internally for smoothing before detecting edges.
import cv2
plt.show()
3. Scale-Invariant Feature Transform (SIFT)
Gaussian filters are used in SIFT to detect keypoints in an image across multiple scales. These
keypoints are essential for tasks like:
Applications:
Photography: Achieve a bokeh effect by blurring the background while keeping the
subject sharp.
import cv2
image = cv2.imread('example_image.jpg')
blurred = cv2.GaussianBlur(image, (15, 15), 5) # Higher kernel size for stronger blur
# Display results
plt.figure(figsize=(10, 5))
plt.show()
5. Denoising in Signal Processing
Gaussian filters are not limited to images; they’re also used in signal processing to smooth
data.
Applications:
Stock Market Analysis: Remove noise from price trends for better forecasting.
6. Object Recognition
Gaussian filters preprocess images for object recognition tasks. Smoothing enhances the
stability of algorithms against minor distortions.
Applications:
7. Focus Stacking
2. Gaussian filters blend them into a single image, preserving sharp details.
Applications:
8. Image Compression
Gaussian filters are used in lossy compression algorithms to reduce high-frequency details
before encoding.
Applications:
JPEG Compression: Gaussian smoothing reduces file size without significant quality
loss.
import cv2
plt.figure(figsize=(10, 5))
plt.show()
Real-World Applications
2. Medical Imaging: Outline structures like blood vessels in X-rays and CT scans.
Edge detection has evolved to address complex challenges in image processing. Advanced
methods build on basic techniques like Sobel, LoG, and Canny to improve robustness, handle
real-world noise, and enable better accuracy in complex environments.
Concept: Detect edges at different levels of detail by applying filters with varying
kernel sizes or σ values (scale-space representation).
Example: Use a Gaussian pyramid, where the image is smoothed and subsampled at
multiple scales.
Applications:
import numpy as np
median = np.median(image)
cv2.imshow(‘Edges’, edges)
cv2.waitKey(0)
cv2.destroyAllWindows()
Steps:
Applications:
Advantages:
Applications:
Solution:
Outcome: Improves safety by accurately identifying lanes even under challenging conditions.
Problem: Detect fine structures like blood vessels in noisy scans (e.g., angiograms).
Solution:
Solution:
Solution:
1. Objective: Compare Sobel, Canny, and Laplacian edge detection on the same image.
2. Steps:
o Load a grayscale image.
import cv2
# Plot results
plt.figure(figsize=(15, 10))
plt.show()
import numpy as np
median = np.median(image)
# Display results
plt.show()
1. Objective: Explore the effect of noise on edge detection and mitigate it using
Gaussian filters.
2. Steps:
o Compare results.
import numpy as np
# Plot results
plt.figure(figsize=(15, 10))
plt.show()
Exercise 4: Object Boundary Detection
2. Steps:
# Display results
plt.figure(figsize=(10, 5))
plt.show()
2. Steps:
cv2.line(lane_image, (x1, y1 + height // 2), (x2, y2 + height // 2), (0, 255, 0), 2)
# Display results
plt.figure(figsize=(10, 5))
plt.show()