0% found this document useful (0 votes)
53 views

Unit 2 CV

The document discusses edge detection techniques in computer vision. It covers several topics: 1) Popular edge detection algorithms like gradient-based methods, Laplacian-based methods, and Canny edge detection. 2) Sources of noise in images like additive stationary Gaussian noise and how it affects edge detection. 3) How smoothing images with filters like Gaussian blur can help make edge detection more robust to noise. 4) How finite differences, which are used to estimate derivatives, are sensitive to noise and how techniques like smoothing can address this.

Uploaded by

Bobby
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Unit 2 CV

The document discusses edge detection techniques in computer vision. It covers several topics: 1) Popular edge detection algorithms like gradient-based methods, Laplacian-based methods, and Canny edge detection. 2) Sources of noise in images like additive stationary Gaussian noise and how it affects edge detection. 3) How smoothing images with filters like Gaussian blur can help make edge detection more robust to noise. 4) How finite differences, which are used to estimate derivatives, are sensitive to noise and how techniques like smoothing can address this.

Uploaded by

Bobby
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

UNIT II EDGE DETECTION Lecture 9Hrs

Noise- Additive Stationary Gaussian Noise, Why Finite Differences


Respond to Noise, Estimating Derivatives - Derivative of Gaussian
Filters, Why Smoothing Helps, Choosing a Smoothing Filter, Why
Smooth with a Gaussian? Detecting Edges-Using the Laplacian to
Detect Edges, Gradient-Based Edge Detectors, Technique:
Orientation Representations and Corners.

EDGE DETECTION

Edge detection is a fundamental technique in computer vision that aims to


identify the boundaries or edges of objects within an image. It is commonly
used as a preprocessing step in various computer vision tasks, such as
object recognition, image segmentation, and feature extraction.

The goal of edge detection is to highlight regions in an image where there


are significant changes in intensity or color. These changes often
correspond to object boundaries, where there is a transition from one
region to another. By detecting these edges, we can extract important
structural information from the image.

There are several popular edge detection algorithms commonly used in


computer vision:

1. **Gradient-based methods:** These methods compute the gradient (rate


of change) of the image intensity at each pixel. The magnitude of the
gradient represents the strength of the edge, while the direction indicates
the edge orientation. The most well-known gradient-based algorithm is the
**Sobel operator**, which convolves the image with a set of small filters to
estimate the gradients.

2. **Laplacian-based methods:** These methods detect edges by


computing the second derivative of the image intensity. The Laplacian of an
image highlights regions of rapid intensity changes. Typically, the Laplacian
operator is applied directly to the image or to a smoothed version of the
image.
3. **Canny edge detection:** The Canny edge detector is a widely used
algorithm known for its good performance and low error rate. It involves
multiple stages, including smoothing the image with a Gaussian filter,
computing gradients, non-maximum suppression to thin the edges, and
hysteresis thresholding to link the edge pixels.

4. **Edge operators based on image derivatives:** These operators, such


as the Prewitt operator and Roberts operator, estimate the derivatives in
different directions and use them to detect edges.

5. **Machine learning-based approaches:** With the advent of deep


learning, convolutional neural networks (CNNs) have been successfully
employed for edge detection. These networks learn to extract edge
features automatically from a large dataset of annotated images.

The choice of edge detection algorithm depends on the specific application,


noise characteristics of the image, and computational constraints. It is
common to experiment with different algorithms and parameters to achieve
the desired edge detection results.

1.1 Noise- Additive Stationary Gaussian Noise

In computer vision, additive stationary Gaussian noise refers to a type of


noise that is commonly encountered in image processing and computer
vision tasks. It is characterized by the addition of random
Gaussian-distributed values to the pixels of an image. This type of noise
can be modeled as an independent and identically distributed (IID)
Gaussian random variable added to each pixel value.

Additive noise refers to the fact that the noise is added to the original
image, rather than being inherent to the image capture process. Stationary
noise means that the noise characteristics, such as its mean and variance,
remain constant throughout the image.
Gaussian noise follows a Gaussian distribution, also known as a normal
distribution, which is a continuous probability distribution characterized by
its mean and standard deviation.

The presence of additive stationary Gaussian noise in images can have


various detrimental effects on computer vision tasks. It can reduce image
quality, introduce unwanted artifacts, and degrade the performance of
algorithms that rely on precise pixel values or feature detection. Therefore,
it is often desirable to employ denoising techniques to reduce or remove the
noise while preserving the important information in the image.

Several methods can be used to address additive stationary Gaussian


noise in computer vision. These methods generally involve filtering
techniques that exploit the statistical properties of the noise and the image.
Common denoising algorithms include Gaussian filtering, median filtering,
bilateral filtering, and wavelet-based methods.

It's worth noting that in practical scenarios, the noise encountered in


real-world images may not always precisely follow a Gaussian distribution
or be stationary. However, the assumption of additive stationary Gaussian
noise is often made for simplification and as a starting point for noise
modeling and denoising algorithm development.

1.2 Why Finite Differences Respond to Noise


Finite differences in computer vision can be sensitive to noise due to their
inherent nature of approximating derivatives or gradients using neighboring
pixel values. Finite differences are commonly used to estimate gradients in
images, which provide valuable information about the image's intensity
variations and object boundaries. However, noise in the image can disrupt
the accuracy of these gradient estimates, leading to undesired effects.

When finite differences are calculated between neighboring pixels, the


assumption is that the intensity variations between those pixels are solely
due to the underlying image
structure. However, in the presence of noise, these intensity variations
become contaminated, making it challenging to differentiate between
genuine image structure and noise.

The main reasons why finite differences respond to noise in computer vision
are:

1. Amplification of noise: Finite differences involve subtracting neighboring


pixel values, which amplifies the noise present in the image. Noise can
have random fluctuations and irregular patterns, and subtracting
neighboring pixels can emphasize these irregularities, leading to an
exaggerated response to noise.

2. Error propagation: When finite differences are used to calculate


gradients, the estimated gradient values are used in subsequent
calculations or algorithms. If the initial gradient estimates are noisy, the
errors get propagated throughout the process, affecting the final results.
This can lead to incorrect feature extraction, edge detection, or other
computer vision tasks.
3. Sensitivity to local variations: Finite differences are sensitive to local
intensity variations, and noise can introduce spurious local variations that
are unrelated to the underlying image structure. As a result, the computed
gradients may not accurately represent the true image gradients, leading to
incorrect interpretations of object boundaries or texture information.

To mitigate the effects of noise on finite differences in computer vision,


various techniques are employed. These include:

- Smoothing filters: Applying filters like Gaussian blur or median filtering


can help reduce noise before computing gradients, thereby minimizing the
influence of noise on the finite difference estimates.
- Regularization: Techniques such as total variation regularization or
Tikhonov regularization can be used to impose smoothness constraints on
the gradients, which helps suppress noise and enhance the robustness of
finite difference-based algorithms.

- Higher-order differences: Instead of using first-order finite differences,


higher-order differences can be employed to estimate gradients. These
methods tend to be more robust to noise since they involve considering a
larger neighborhood of pixels.

- Denoising algorithms: Prior denoising techniques can be applied to the


image to remove noise before computing finite differences. This can involve
methods like wavelet denoising, non-local means, or other advanced
denoising algorithms.

By employing these strategies, the impact of noise on finite differences can


be minimized, resulting in more reliable and accurate computer vision
algorithms.

1.3 Estimating Derivatives - Derivative of Gaussian Filters


The derivative of Gaussian filters, also known as the Gaussian derivative
filters or simply the derivative filters, are widely used in computer vision for
various tasks such as edge detection, image enhancement, and feature
extraction. These filters are typically applied to an image to compute the
gradients or edge responses.

To estimate the derivative of a Gaussian filter, we need to differentiate the


Gaussian function with respect to the spatial variables (x and y) and
possibly the scale parameter (σ). Let's consider a 2D Gaussian filter
centered at the origin:

G(x, y; σ) = exp(-(x^2 + y^2) / (2σ^2)) / (2πσ^2)

The derivatives of the Gaussian filter can be computed by taking partial


derivatives of the Gaussian function. We'll consider the first-order
derivatives in this explanation:

1. Derivative with respect to x:

∂ G/∂ x = -(x / σ^2) * G(x, y; σ)


2. Derivative with respect to y:

∂ G/∂ y = -(y / σ^2) * G(x, y; σ)

Note that the derivatives are multiplied by the respective spatial variables (x
and y) divided by the square of the scale parameter (σ^2), and then
multiplied by the value of the Gaussian function at that point.

These derivatives represent the gradients of the Gaussian filter in the x and
y directions, respectively. They indicate the rate of change of the Gaussian
function at each point in the image.

In practice, to estimate the derivatives of a Gaussian filter, the filter is


discretized by sampling points from the continuous Gaussian function, and
the partial derivatives are computed based on these samples. The discrete
approximations can be obtained using finite difference methods or by
convolving the discrete Gaussian filter with the respective derivative
kernels.

The derivative of Gaussian filters of higher orders can also be computed by


taking higher order partial derivatives of the Gaussian function. These
higher-order derivatives are used for tasks such as corner detection or blob
detection, where more detailed information about image structures is
required.

It's worth noting that there are precomputed approximations of Gaussian


derivative filters known as "derivative of Gaussian kernels" that are
commonly used in computer vision libraries and algorithms. These
precomputed kernels provide efficient and accurate approximations of the
Gaussian derivatives for different scales and orders, avoiding the need for
repeated computations during runtime.
Overall, the derivative of Gaussian filters play a crucial role in computer
vision algorithms, enabling the extraction of important image features and
facilitating various image processing tasks.

1.4 Why Smoothing Helps

Smoothing, also known as blurring, is a technique commonly used in


computer vision to enhance image quality and reduce noise. It involves
applying a filter to an image that averages the pixel values within a
neighborhood or region. Smoothing helps in computer vision for the
following reasons:

1. Noise reduction: Images captured by cameras or generated through


sensors often contain unwanted noise due to various factors such as
sensor limitations, compression artifacts, or environmental conditions.
Smoothing filters can effectively reduce noise by averaging out pixel
values, resulting in a cleaner and more visually pleasing image.

2. Edge preservation: Smoothing filters can be designed to preserve


important edges while reducing noise. By carefully adjusting the filter
parameters, it is possible to smooth the image while maintaining the
sharpness of edges. This is particularly useful in applications such as edge
detection or object recognition, where preserving the integrity of object
boundaries is crucial.

3. Image preprocessing: Smoothing is often used as a preprocessing step


before performing more complex computer vision tasks. By reducing noise
and suppressing small details, smoothing can simplify subsequent image
analysis algorithms. For example, it can help in improving the accuracy of
feature extraction techniques like corner detection or blob detection by
removing unwanted noise and enhancing the saliency of relevant features.

4. Texture analysis: Smoothing filters can also aid in texture analysis tasks.
By reducing high-frequency noise and fine details, smoothing can make it
easier to analyze and characterize textures in an image. It can help in tasks
like texture classification,
segmentation, or pattern recognition, where the overall texture information
is more important than fine-scale details.

5. Image enhancement: In certain applications, smoothing can be used as


a tool for image enhancement. By reducing noise and blurring unwanted
details, the overall visual quality of an image can be improved. Smoothing
can help in applications like image denoising, deblurring, or image resizing,
where the goal is to obtain a visually appealing result rather than preserving
fine details.
It's important to note that while smoothing can be beneficial in various
computer vision tasks, the choice of the smoothing technique and
parameters should be carefully considered based on the specific
requirements of the application at hand. Different smoothing filters have
different characteristics, and choosing the right one is essential to achieve
the desired outcome.

1.5 Choosing a Smoothing Filter

When choosing a smoothing filter in computer vision, you need to consider


the specific requirements of your application and the characteristics of the
image you're working with. Smoothing filters, also known as blurring filters,
are used to reduce noise and remove fine details from an image, resulting
in a smoother appearance. Here are a few common smoothing filters and
their characteristics:

1. Gaussian filter: The Gaussian filter is widely used for smoothing because
it effectively reduces noise while preserving edges. It applies a weighted
average to the neighboring pixels, with the weights determined by a
Gaussian function. The size of the filter kernel (i.e., the window used for
averaging) and the standard deviation of the Gaussian determine the
amount of smoothing applied.

2. Box filter: The box filter, also known as the average filter, applies a
simple averaging operation to the neighboring pixels within a rectangular
window. It provides a uniform
smoothing effect across the image but may not preserve edges as well as
the Gaussian filter. The size of the filter kernel determines the extent of
smoothing.

3. Median filter: The median filter is effective at removing impulse noise,


such as salt-and-pepper noise. It replaces each pixel with the median value
of the pixels within a defined neighborhood. This filter can preserve edges
better than linear filters like Gaussian or box filters but may not smooth
continuous regions as effectively.

4. Bilateral filter: The bilateral filter considers both spatial distance and
intensity similarity when smoothing an image. It preserves edges while
reducing noise by applying a weighted average to neighboring pixels based
on their spatial proximity and intensity differences. The filter parameters
include the spatial and intensity standard deviations, which control the size
of the neighborhood and the strength of the filtering, respectively.

The choice of a smoothing filter depends on the characteristics of the noise


you want to remove, the level of detail you wish to preserve, and the
computational efficiency required for your application. It's often a trade-off
between noise reduction and preserving important image features.
Experimentation and visual inspection of the results with different filters can
help determine the most suitable option for your specific task.

1.6 Why Smooth with a Gaussian

Smoothing with a Gaussian filter is a commonly used technique in


computer vision and image processing for several reasons:

1. Noise reduction: Gaussian smoothing helps reduce the effect of noise in


an image. In real-world scenarios, images often contain unwanted
high-frequency noise caused by sensor limitations, transmission errors, or
other factors. By convolving the image with a Gaussian kernel, the
high-frequency components associated with noise are attenuated, resulting
in a smoother image.
2. Edge preservation: Gaussian smoothing can help preserve important
edges and boundaries in an image while reducing noise. Unlike other
simple smoothing filters, such as the average filter, a Gaussian filter
considers the neighborhood pixels' weights according to their distance from
the center pixel. This weighted averaging preserves edges better since
nearby pixels contribute more to the filtered value than distant pixels.
As a result, the Gaussian filter reduces noise while maintaining sharp
transitions at edges.

3. Scale-space representation: The Gaussian filter is scale-invariant, which


means it can be used to create a scale-space representation of an image.
By applying Gaussian smoothing with different standard deviations (sigma
values) to an image, multiple versions of the image can be obtained at
different levels of detail. This scale-space representation is useful for
various computer vision tasks, such as feature extraction, blob detection,
and multi-scale analysis.

4. Pre-processing for other algorithms: Gaussian smoothing is often used


as a pre-processing step before applying other computer vision algorithms.
By reducing noise and removing fine details that may not be relevant to the
subsequent processing steps, Gaussian smoothing can improve the
performance and reliability of various algorithms like edge detection, image
segmentation, or object recognition.

Overall, Gaussian smoothing is a versatile technique in computer vision


that offers noise reduction, edge preservation, scale-space representation,
and pre-processing benefits. It finds widespread applications in various
image processing tasks to improve image quality, enhance features, and
facilitate subsequent analysis.

1.7 Detecting Edges-Using the Laplacian to Detect Edges


Edge detection is an essential technique in computer vision used to identify
boundaries between different objects or regions in an image. One popular
method for detecting edges is by using the Laplacian operator.
The Laplacian operator is a second-order derivative operator that measures
the rate of change of intensity in an image. It calculates the sum of
second-order partial derivatives of the image with respect to the x and y
coordinates. By applying the Laplacian operator, regions with high intensity
variations, such as edges, will exhibit high positive or negative values.

Here are the steps to perform edge detection using the Laplacian operator:

1. Convert the image to grayscale: Edge detection is typically performed on


grayscale images. If your image is in color, convert it to grayscale using
appropriate color-to-grayscale conversion methods.

2. Apply Gaussian smoothing (optional): Before applying the Laplacian


operator, it can be beneficial to smooth the image using a Gaussian filter to
reduce noise and eliminate small variations. This step helps avoid detecting
spurious edges caused by noise. Smoothing can be achieved by
convolving the image with a Gaussian kernel.

3. Apply the Laplacian operator: Convolve the preprocessed image with the
Laplacian filter. The Laplacian filter is a discrete approximation of the
second derivative of the image intensity. It is a 3x3 or 5x5 kernel with
specific values that capture the second-order differences in the image.

For example, a commonly used 3x3 Laplacian kernel is:

```

010

1 -4 1

010
```
For more enhanced results, you can also use a 5x5 kernel or other
variations.

4. Adjust the threshold: The output of the Laplacian operator will contain
both positive and negative values. To obtain a binary edge map, you need
to apply a threshold to determine which values are considered edges and
which are not. You can set a fixed threshold value or use adaptive methods
based on the local intensity gradient.

5. Post-processing (optional): Depending on the application and the quality


of the edge map, you might want to perform additional post-processing
steps such as edge linking, thinning, or noise removal to improve the
accuracy and cleanliness of the detected edges.

It's important to note that the Laplacian operator can be sensitive to noise
and produce thick edges. To mitigate these issues, alternative edge
detection methods like the Canny edge detector, which combines multiple
steps including smoothing, gradient computation, non-maximum
suppression, and hysteresis thresholding, are commonly used in practice.

Implementations of edge detection algorithms, including the Laplacian


operator, are available in popular computer vision libraries such as
OpenCV, MATLAB, and scikit-image.

1.8 Gradient-Based Edge Detectors

Gradient-based edge detection is a fundamental technique in computer


vision used to identify and localize edges in digital images. It aims to
capture regions of significant intensity variations, which often correspond to
object boundaries or structural changes in the scene. Gradient-based edge
detectors operate by analyzing the gradient or the first-order derivative of
an image.
One of the most widely used gradient-based edge detection operators is
the Sobel operator. The Sobel operator applies a pair of convolutional
kernels to the image, one for detecting horizontal edges and the other for
vertical edges. These kernels compute the gradient of the image intensity
in the respective directions and combine them to estimate the edge
strength and orientation at each pixel.

The Sobel operator can be represented as follows:

Horizontal Sobel kernel:

```

-1 0 1

-2 0 2

-1 0 1

```

Vertical Sobel kernel:

```

-1 -2 -1

000

121

```

To detect edges, the Sobel operator convolves these kernels with the input
image. The result is two gradient images representing the approximate
derivatives of the image in the horizontal and vertical directions. These
gradient images are then combined to compute the edge strength and
orientation.
The edge strength is typically calculated as the magnitude of the gradient
vector at each pixel, given by:

```

strength = sqrt((Gx^2) + (Gy^2))

```

where Gx and Gy are the gradients computed in the horizontal and vertical
directions, respectively.

The orientation of the edge can be determined using the

arctan function: ```

orientation = atan2(Gy, Gx)

```

Once the edge strength and orientation are obtained, further processing
steps can be applied, such as thresholding to identify significant edges and
non-maximum suppression to thin out the detected edges.

Other gradient-based edge detectors include the Prewitt operator, which is


similar to the Sobel operator but uses slightly different kernels, and the
Roberts operator, which estimates the gradients using simple difference
operators.

Gradient-based edge detectors are widely used due to their simplicity and
effectiveness in capturing image structures. However, they are sensitive to
noise, and their performance can be limited in the presence of low-contrast
edges or in complex scenes. Therefore, more advanced edge detection
techniques, such as the Canny edge detector, have been developed to
overcome these limitations by incorporating additional processing steps.
1.9 Technique: Orientation Representations and Corners.

In computer vision, orientation representations and corners are essential


techniques used for various tasks such as image processing, feature
detection, object recognition, and tracking. These techniques help to
capture important information about the structure and geometry of an
image.

Orientation Representations:

Orientation representations refer to methods of describing the orientation or


directionality of image features. They are particularly useful for detecting
edges or gradients in an image. Some commonly used orientation
representations include:

1. Gradient Orientation: The gradient orientation represents the direction of


the intensity change at each pixel in an image. It is typically calculated
using gradient operators like the Sobel operator or the Prewitt operator.
The gradient magnitude and orientation together provide information about
the edges and contours present in an image.

2. Histogram of Oriented Gradients (HOG): HOG is a widely used


technique for object detection and human detection. It computes the
gradient orientation for small image regions called cells and then creates a
histogram of these orientations within each block. The HOG descriptor
captures the distribution of edge orientations, which can be used to identify
objects or distinguish between different object classes.

Corners:
Corners are distinctive features in an image that have high local variations
in intensity or color. They represent the intersection of edges and can be
used for tasks like image registration, tracking, and stereo vision. Corner
detection algorithms aim to identify these points in an image. Some popular
corner detection methods include:
1. Harris Corner Detector: The Harris corner detector is one of the earliest
and most widely used methods for corner detection. It calculates the corner
response function by analyzing the local intensity variations in different
directions. Corners are identified as points with large corner response
values.

2. Shi-Tomasi Corner Detector: The Shi-Tomasi corner detector is an


improvement over the Harris corner detector. It selects only the most
prominent corners based on a quality measure called the minimum
eigenvalue. This approach provides more robust corner detection by
considering the eigenvalues of the corner response matrix.

Corners are valuable features because they are relatively invariant to


changes in scale, rotation, and lighting conditions, making them useful for
tasks like image stitching, 3D reconstruction, and visual odometry.

Overall, orientation representations and corner detection techniques play a


crucial role in computer vision by capturing important visual information and
enabling various applications such as image analysis, object recognition,
and tracking.

You might also like