Title: Filtering and Image Enhancements
1Filtering and Image Enhancements
- Dr. Ramprasad Bala
- Computer and Information Science
- UMASS Dartmouth
- CIS 465 Topics in Computer Vision
2Introduction
- Image processing more accurately filtering,
enhancement or conditioning is the process of
extracting the signal or structure in the image
while suppressing unwanted or uninteresting
variations in the image. - Operations can be based on local neighborhood or
on the entire image. - Correlation or Convolution.
3What needs fixing?
Image Enhancement
4Image Enhancement
- Image enhancement operators improve detectability
of important image details or objects manually or
automatically. - Noise reduction/suppression
- Smoothing
- Contrast stretching
- Edge enhancement
5Image Restoration
6Image Restoration
- Image restoration attempts to restore a degraded
image to an ideal condition for further
processing. - Constrained by the understanding and modeling of
the ideal image formation and image degradation
process. - If successful we can use the model to invert the
degradation to return the ideal image.
7Gray-level Mapping
- Change the appearance of an image by transforming
the pixels via a single function that maps an
input gray-value into a new output value. - This can be done to the entire image or to use
different functions for different sub-images. - Remapping the gray values is called stretching
8Example
9Example
10Gamma correction
- Any function map can be used.
- The square root function (f(x) x ½ ) for
example boosts, nonlinearly, all intensities, but
more so the lower intensities than higher ones. - The function f(x) x 1/? is called Gamma
correction. Where ? can be varying. - Image variation will be increased in the
intensity ranges where the slope of the function
is greater than 1.
11Point operator
- A point operator applied to an image is an
operator in which the output pixel is determined
only by the input pixel, - Outx,y f(Inx,y)
- function f() may depend on some global
parameter. - A contrast stretching operator is a point
operator that used a piecewise smooth function
f(Inx,y) of the input gray level to enhance
important details of the image.
12Disclaimer
- While monotonic point operators work well in
enhancing images for human consumption (or
graphics etc), they do change the original
intensities considerably. - In applications where the original intensity
levels play a significant role (eg. mammography
images) point operators are not good solutions
for image enhancement.
13Histogram Equalization
- Histogram equalization is often used to enhance
an image. - It accomplishes the following
- The output image uses all available gray levels
- The output image has approximately the same
number of pixels of each gray level. - While a. makes sense, b. is ad hoc and its
effectiveness can be judged only empirically.
14Histogram Equalization
15Histogram Equalization
16Mathematically Speaking
- Condition a. implies that all gray levels will be
representedz z1,z z2z zn - Condition b. implies that gray level zk is used q
times where q (RxC)/n, where R,C and n are
number of rows, number of columns and number of
intensities in the image respectively.
17Implementation
- Hini is the number of pixels of the input image
having gray level zi. - The first gray level threshold t1is found by
advancing I in the input image histogram until
approximately q1 pixels are accounted for
i.e.all input image pixels zk lt t1 1 will be
mapped to gray level z1 in the output image.
18Assignment 6
- Implement histogram equalization.
- Your program will take as input the number of
intensities you want represented in the image. - Display the original image, its intensity
histogram, the output image and its intensity
histogram. The assignment should run off of a
gui. - Due March 21th.
19Noise Removal
- Salt and Pepper Noise.
- The presence of a single bright pixel in a dark
region or vise versa is called Salt and Pepper
noise. - Typically results from classification errors
resulting from variation in surface material or
illumination. - A (4- or 8 neighbor) mask is usually applied to
eliminate this noise. - CC can also be used for removal of small regions.
20(No Transcript)
21Image Smoothing
- Smoothing an image by equally weighting a
rectangular neighborhood of pixels is called
using a box filter. - Mean filter use the average of it neighbors
22Original image modified with some gaussian noise.
23Gaussian Filter
- Instead of weighting the neighbors equally you
could weight them based on their distance from
the center pixel. - When a Gaussian filter is used, pixel x,y is
weighted according to - where d sqrt((x-xc)2 (y-yc)2).
- More on this later
24Median Filter
- The Mean filter usually works if the regions tend
to be homogenous. - The Median Filter replaces the center pixel with
the median of the neighboring values. - Works well for many types of noise.
- Preserves edges, unlike the mean filter.
- Computationally expensive, due to sorting.
255x5 Median Filter
7x7 Median Filter
26Another Example
27Detecting Edges Using Differencing Masks
- Image points of high contrast can be detected by
computing intensity differences in local image
regions. - Differencing in the 1-D signal
- The derivative would be discretely computed by
subtracting successive values. - In the form a mask it will look like this
- M
28(No Transcript)
29Difference masks can be used to obtain different
results. I only the presence of an edge is
important, you can simply compute the absolute.
If direction of the edge is important then leave
the sign in there. In the former case -1 1
would be equivalent mask to 1 1. Similarly for
the second derivative, The mask 1 2 1 would
be equivalent to -1 2 1. The first derivative
gives you information about sharp changes. The
second derivative gives you information on
zero-crossing.
30First derivative mask
31Second derivative mask
32Smoothing versus differencing
33Properties of Differencing
- Coordinates of derivative masks have opposite
signs in order to obtain a high response in
signal regions of high contrast. - The sum of coordinates of derivative masks is
zero so that zero response is obtained on
constant regions. - First derivative masks produce high absolute
values at points of high contrast. - Second derivative masks produce zero-crossing at
points of high contrasts.
34Properties of Smoothing Masks
- Coordinates of smoothing masks are positive and
sum to one so that output on constant regions is
the same as the input. - The amount of smoothing and noise reduction is
proportional to the mask size. - Step edges are blurred in proportion to the mask
size.
35Different operators on 2D signals.
- From calculus we know that the derivative of a 2D
function is given by - df/dx df/dy and the direction is given by
tan-1 of these two values. - Since an edge might cut across an edge we may
want to use more than one point to find the
difference.
36So the difference is defined as
37Intuitively
38Transforming this into a mask...
39Applying this mask to an image
40(No Transcript)
41The Sobel Operator
42Analysis
43Notes on using these operators
- The Roberts mask is more efficient due to smaller
neighborhood operation. - All these local operators miss a lot of edges.
- Computing square roots and squares can become
quite expensive other variations include,
absolute, maximum.
44Zero crossings of the second derivative
- The main disadvantage of these edge detectors is
their dependence on the size of objects and
sensitivity to noise. - An edge detection technique, based on the zero
crossings of the second derivative explores the
fact that a step edge corresponds to an abrupt
change in the image function. - The first derivative of the image function should
have an extrema at the position corresponding to
the edge in the image, and so the second
derivative should be zero at the same position.
45Gaussian Filtering and LoG
- A Gaussian function of one variable with spread s
is of the following form - A Gaussian function in two variables is shown
below
46Laplacian of the Gaussian
- Robust calculation of the 2nd derivative
- smooth an image first (to reduce noise) and then
compute second derivatives. - the 2D Gaussian smoothing operator G(x,y)
47LoG
- After returning to the original co-ordinates x, y
and introducing a normalizing multiplicative
coefficient c (that includes 1/ 2), we get a
convolution mask of a zero crossing detector - where c normalizes the sum of mask elements to
zero.
48(No Transcript)
49(No Transcript)
50Some Properties
- The area under the curve of g(x) making it
suitable for being used as a filter. - g(x) is g(x) multiplied by the function x and
one over s2. - g(x) is the difference of two even functions
and the central lobe will be negative when x is
approximately 0. The zero crossings occur when x
s2.
51Examples of G-masks
52LoG
53A large LoG filter
54LOG Roberts Prewitt Sobel
55Neural Networks
56Marr-Hildreth Theory
57(No Transcript)
58The Canny Edge Detector
- Smoothes the intensity image and then produces
extended contour segments by following high
gradient magnitudes from one neighborhood to
another. - Details in chapter 10.
59(No Transcript)
60