# Neural Networks | angular代写 | Machine learning代写 | Computer Vision | cv代写 – Computer Vision Image Processing II

### Computer Vision Image Processing II

Neural Networks | angular代写 | Machine learning代写 – 这道题目是利用angular进行的编程代写任务, 包括了Neural Networks/angular/Machine learning等方面

``````COMP9517 2022 T2 1
``````
• Two main types of image processing operations:
• Spatial domain operations (in image space)
• Frequency domain operations (mainly in Fourier space)
• Two main types of spatial domain operations:
• Point operations (intensity transformations on individual pixels)
• Neighbourhoodoperations (spatial filtering on groups of pixels)

Types of image processing (recap)

Point operations

Neighbourhood operations

Recap

Spatial domain, intensity transformations (on

single pixels)

• Image thresholding
• Otsus method
• Histogram thresholding
• Multiband thresholding
• Image inversion
• Log transform
• Power-law
• Averaging

Recap

Spatial domain, intensity transformations (on

single pixels)

• Piecewise-linear transformation
• Contrast stretching
• Gray-level slicing
• Bit-plane slicing
• Histogram processing
• Histogram equalization
• Histogram matching

Spatial Filtering

• These methods use a small neighbourhood of a pixel in the input image to produce a new brightnessesvalue for that pixel
• Also called filtering techniques
• Neighbourhood of (,)is usually a square or rect angular subimage centred at ,.
• filter / mask / kernel / template / window is used to indicate the concepts of the subimageor the corresponding operators, in different contexts.

Spatial Filtering

• These methods use a small neighbourhood of a pixel in the input image to produce a new brightnessesvalue for that pixel
• Also called filtering techniques
• Neighbourhood of (,)is usually a square or rectangular subimage centred at ,.
• A linear transformation calculates a value in the output image , as a linear combination of brightnessesin a local neighbourhood of the pixel in the input image (,)weighted by coefficients :
##### , =
``````=
``````
``````

=
``````
``````
, (,)
``````
• This is called a discrete convolution with the convolution mask/filter/kernel

Spatial Filtering

Convolution

Smoothing Spatial Filters

Neighbourhood Averaging (Mean Filter)

• The most basic filter, used for image blurring/smoothing and

noise reduction

, =

``````1

``````

(,)(,)

• Replace intensity at pixel (,)with the average of the

intensities in a neighbourhood of (,)

• We can also use a weighted average , giving more importance
``````to some pixels over others in the neighbourhood  can reduce
blurring effect
``````
• Neighbourhood averaging blurs edges

Digital Image Processing – Chapter 3, Image Enhancement in the Spatial Domain

Smoothing Spatial Filters –

Examples

Smoothing Spatial Filters –

Examples

Digital Image Processing – Chapter 3, Image Enhancement in the Spatial Domain

Smoothing Spatial Filters

``````Smoothing Spatial Filters
``````
• Aim: To suppress noise, other small fluctuations in image- may be result of sampling, quantization, transmission, environment disturbances during acquisition
• Uses redundancy in the image data
• May blur sharp edges, so care is needed

What if the filter is 0 0 0 0 0 0 0 1 0 or 0 0 1 0 0 0 0 0 0?

Gaussian Filter

,, =

``````1
2^2
``````

``````
``````

(^2) + 2 2^2

• Replace intensity at pixel (,)with the weighted average of

the intensities in a neighbourhood of (,)

• It is a set of weights that approximate the profile of a

Gaussian function

• It is very effective in reducing noise and alsoreducing details

(image blurring)

Gaussian Filter

Gaussian Filter

Many nice properties motivate the use of the Gaussian filter

• It is the only filter that is both separable and circularly symmetric
• It has optimal space-frequency localization
• The Fourier transform of a Gaussian is also a Gaussian function
• The n -fold convolution of any low-pass filter converges to a Gaussian
• It is infinitely smooth so it can be differentiated to any desired degree
• It scales naturally (sigma) and allows for consistent scale-space theory
``````=0.
``````
``````3 x 3 5 x 5
=1.
``````
``````7 x 7
=1.
``````
``````9 x 9
=2.
``````
``````11 x 11
=2.
``````

Nonlinear Spatial Filters

Referring to order-statistics filters in many cases: response based on ordering the pixels in the neighbourhood and replacing centre pixel with the ranking result

Median Filter

• Intensity of each pixel is replaced by the median of the intensities in neighbourhood of that pixel
• Median M of a set of values is the middle value such that half the values in the set are less than M and the other half greater than M

Median Filter

``````19
``````

69 37 19

51 43 44

48 58 68

``````?
``````
``````69 37 19 51 43 44 48 58 68
19 37 43 44 48 51 58 68 69
``````

Nonlinear Spatial Filters

Median Filter

• Intensity of each pixel is replaced by the median of the intensities in neighbourhood of that pixel
• Median filtering forces points with distinct intensities to be more like their neighbours, thus eliminating isolated intensity spikes
• Also, isolated pixel clusters (light or dark), whose area is ^2 /2are eliminated by an median filter
• Good for impulse noise (salt-and-pepper noise)
• Other examples of order-statistics filters are max and min filters
``````Image with impulse noise (salt-and-
pepper noise)
``````

#### Median Filter

``````  -
``````
• ## -?

Chapter 3

Image Enhancement in the

Spatial Domain

#### Gaussian Versus Median Filtering

``````Original Gaussian Median
``````

Example 1

Example 2

Max / average / median pooling Provides translation invariance Reduces computations Popular in deep convolutional Machine learning 人工智能”> Neural Networks (deep learning) Extracting the most essential/significant information

Pooling

Sharpening Spatial Filters

Edge Detection

• Goal is to highlight fine detail, or enhance detail that has been

blurred

• Spatial differentiation is the tool; strength of response of
``````derivative operator is proportional to degree of discontinuity
of the image at the point where operator is applied
``````
• Image differentiation enhances edges, and de-emphasizes

slowly varying gray-level values.

Derivative Definitions

For 1-D function f(x), the first order derivative is

approximated as:

``````

``````

= ( + 1) ()

The second-order derivative is approximated as:

``````^2
^2
``````

= ( + 1) 2() + ( 1)

These are partial derivatives, so extension to 2D is easy

Chapter 3

Image Enhancement in the

Spatial Domain

Basic Idea

• Horizontal scan of the image
• Edge modelled as a ramp to represent blurring due to sampling
• First derivative is
• Non-zero along ramp
• zero in regions of constant intensity
• constant during an intensity transition
• Second derivative is
• Nonzero at onset and end of ramp
• Stronger response at isolated noise point
• zero everywhere except at onset and termination of intensity transition
• Thus, magnitude of first derivative can be used to detect the presence of an edge, and sign of second derivative to determine whether a pixel lies on dark or light side of an edge.

Summary

• First-order derivatives produce
``````thicker edges, have stronger
response to gray-level step
``````
• Second-order derivatives
``````produce stronger response to
fine detail (thin lines, isolated
points), produce double
response at step changes in gray
level
``````

First-order derivatives implemented using magnitude of the gradient

For function the gradient at (,)has components = , =

``````

``````

The magnitude of the gradient vector is

`````` = ^2 +^2
``````

This is sometimes approximated as = +

and are linear and may be obtained by using masks

We use numerical techniques to compute these, giving rise to different

Chapter 3

Image Enhancement in the

Spatial Domain

Week 2 COMP9517 2022 T2 32

``````Largest gradients
``````
``````(,)
``````
``````(,)
``````
``````(,)
``````
``````(,)
``````
``````32
``````

Laplacian Operator

Second order derivatives based on the Laplacian. For a function (,)the Laplacian is defined by

This is a linear operator, as all derivative operators are. In discrete form:

and similarly in y direction.

Summing them gives us

``````2 (^1 , ) (^1 , )^2 ( , )
``````
``````2
f x y f x y f x y
x
``````
``````f
= + +

``````
``````
``````
``````^2 (,) = + 1, + 1, + ,+ 1 + , 1 4(,)
``````

Chapter 3

Image Enhancement in the

Spatial Domain

Laplacian Operator

Week 2 COMP9517 2022 T2 35

``````Zero crossings
``````
``````(,)
``````
``````(,)
``````
``````(,)
``````
``````^2 (,)
``````
``````35
``````

``````Week 2 COMP9517 2022 T2 36
``````
``````Edges from thresholding local maxima of the gradient magnitude image
``````

Edges from finding the zero-crossings of the Laplacian image

`````` = 1  = 3  = 5  = 7  = 9
``````
`````` = 1  = 3  = 5  = 7  = 9
``````

``````36
``````

The Laplacian

• There are other forms of the Laplacian, which can include

diagonal directions, for example

• Laplacian highlights grey-level discontinuities and produces

dark featureless backgrounds

• The background can be recovered by adding or subtracting

the Laplacian image to the original image

Chapter 3

Image Enhancement in the

Spatial Domain

Chapter 3

Image Enhancement in the

Spatial Domain

Chapter 3

Image Enhancement in the

Spatial Domain

Chapter 3

Image Enhancement in the

Spatial Domain

• When we use spatial filters for pixels on the
``````boundary of an image, we do not have enough
neighbours
``````
• To get an image with the same size as input image
``````o Zero : set all pixels outside the source image to 0
o Constant : set all pixels outside the source image to a specified border
value
o Clamp : repeat edge pixels indefinitely
o Wrap : copy pixels from opposite side of the image
o Mirror : reflect pixels across the image edge
``````

``````COMP9517 2022 T2 43
``````Szeliski, Computer Vision, Chapter 3