Image enhancement in the spatial domain can be represented as: gm,n = Tfm,n The transformation T maybe linear or nonlinear.. The mask operation can be implemented in MATLAB using
Trang 1 Prof Duong Anh Duc
Trang 2 Image enhancement in the spatial domain can be represented as:
g(m,n) = T(f)(m,n)
The transformation T maybe linear or nonlinear We will mainly study linear operators T but will see one important nonlinear operation
Enhanced Image
Transformation
Given Image
Trang 3 If the operator T is linear and shift invariant (LSI), characterized by the point-spread sequence (PSS) h(m,n) , then (recall convolution)
Trang 4 In practice, to reduce computations, h(m, n) is of “finite extent:
h(k, l) = 0 for (k, l) where is a small set (called neighborhood) is also called as the support of h
In the frequency domain, this can be represented as:
G(u,v) = He(u,v) Fe(u,v)
where He(u,v) and Fe(u,v) are obtained after appropriate
zeropadding
Trang 5 Many LSI operations can be interpreted in the frequency domain as a
“filtering operation.” It has the effect of filtering frequency components (passing certain frequency components and stopping others)
The term filtering is generally associated with such operations
Trang 6 Examples of some common filters (1-D case):
Lowpass filter Highpass filter
Trang 8 The output g(m, n) is computed by sliding the mask over each pixel of the image f(m, n) This filtering procedure is sometimes referred to as moving average filter
Special care is required for the pixels at the border of image f(m, n) This depends on the so-called boundary condition Common choices are:
o The mask is truncated at the border (free boundary)
o The image is extended by appending extra rows/columns at the
boundaries The extension is done by repeating the first/last row/column or
by setting them to some constant (fixed boundary)
o The boundaries “wrap around” (periodic boundary)
Trang 9 In any case, the final output g(m, n) is restricted to the support of the original image f(m, n)
The mask operation can be implemented in MATLAB using the
filter2 command, which is based on the conv2 command
Trang 10 Image smoothing refers to any image-to-image transformation
designed to “smooth” or flatten the image by reducing the rapid to-pixel variation in grayvalues
pixel- Smoothing filters are used for:
o Blurring: This is usually a preprocessing step for removing small
(unwanted) details before extracting the relevant (large) object, bridging gaps in lines/curves,
o Noise reduction: Mitigate the effect of noise by linear or nonlinear
operations
Trang 11 Smoothing is accomplished by applying an averaging mask
An averaging mask is a mask with positive weights, which sum to 1 It computes a weighted average of the pixel values in a neighborhood This operation is sometimes called neighborhood averaging
Some 3 x 3 averaging masks:
This operation is equivalent to lowpass filtering
Trang 12Original Image Avg Mask
Trang 13N = 3 N = 7
Trang 14N = 11 N = 21
Trang 15Noise-free Image
Trang 16Zero-mean Gaussian noise, Variance = 0.01
Trang 17Zero-mean Gaussian noise, Variance = 0.05
Trang 18 The averaging filter is best suited for noise whose distribution is
Gaussian:
The averaging filter typically blurs edges and sharp details
The median filter usually does a better job of preserving edges
Median filter is particularly suited if the noise pattern exhibits strong
(positive and negative) spikes Example: salt and pepper noise
Trang 19 Median filter is a nonlinear filter, that also uses a mask Each pixel is replaced by the median of the pixel values in a neighborhood of the
given pixel
Suppose A ={a1, a2, …, ak} are the pixel values in a neighborhood of
a given pixel with a1 a2 … ak Then
Note: Median of a set of values is the “center value,” after sorting
For example: If A ={0,1,2,4,6,6,10,12,15} then median(A) = 6
Trang 20Gaussian noise: s = 0.2 Salt & Pepper noise: prob = 0.2
Trang 21MSE = 0.0075 MSE = 0.0125
Output of 3x3 Averaging filter
Trang 22MSE = 0.0089 MSE = 0.0042
Output of 3x3 Median filter
Trang 23 This involves highlighting fine details or enhancing details that have been blurred
Trang 24 This can be accomplished by a linear shift-invariant operator,
implemented by means of a mask, with positive and negative
coefficients
This is called a sharpening mask, since it tends to enhance abrupt
graylevel changes in the image
The mask should have a positive coefficient at the center and negative coefficients at the periphery The coefficients should sum to zero
Trang 25 Example:
This is equivalent to highpass filtering
A highpass filtered image g can be thought of as the difference
between the original image f and a lowpass filtered version of f :
g(m, n) = f(m, n) – lowpass(f(m, n))
Trang 26Highpass filtering
Original Image
Trang 27 This is a filter whose output g is produced by subtracting a lowpass
(blurred) version of f from an amplified version of f
g(m,n) = A f(m,n) – lowpass(f(m,n))
This is also referred to as unsharp masking
Trang 29Highpass filtering
Original Image
Trang 30 Averaging tends to blur details in an image Averaging involves
Trang 31 The magnitude of the gradient is:
Discrete approximations to the magnitude of the gradient is normally used
Trang 32 Consider the following image region:
We may use the approximation:
z1 z2 z3
Trang 33 This can implemented using the masks:
As follows:
Trang 34 Alternatively, we may use the approximation:
This can implemented using the masks:
As follows:
Trang 35 The resulting maks are called Roberts cross-gradient operators
The Roberts operators and the Prewitt/Sobel operators (described
later) are used for edge detection and are sometimes called edge
detectors
Trang 38 Better approximations to the gradient can be obtained by:
This can be implemented using the masks:
as follows:
Trang 39 Another approximation is given by the masks:
The resulting masks are called Sobel operators