chương 1: xử lý ảnh
Trang 1DIGITAL IMAGE PROCESSING
Trang 2
3.1 Introduction
Objective of Image Enhancement : to process an image so that the processed image
is more suitable than the original image for a specific application
Relation of Enhancement and Restoration : in image restoration, an original image has been degraded and the objective is to make the processed image resemble the original image as much as possible
Classification of Enhancement Techniques
Point Operations : on each pixel, the input gray level is mapped into a new one
Sapatial Operations : spatial filtering
Transform Operations : manipulation in transform domain
Trang 3¢ Clipping : a special case of contrast stretching where a =y =0 (Fig 3.2.1)
useful for noise reduction of the input signal known to lie in fa, 5]
should be performed on images that will be represented with a finite number of bits, for example, with unsigned character
Department of Biomedical Engineering
Trang 4Other Simple Operations
« Image negative: v=L—u, u,ve [0,L]
Fig 3.2.3 (a)(c) Original images, (b)(d) negative images
Trang 6
« Range Compression: The dynamic range of a unitarily transformed image is so
large that only a few pixels are visible The dynamic range can be compressed via
the logarithmic transformation
v=clog,(I+|w|) where c isascaling constant
« Image Subtraction: In many imaging applications it is desired to compare two
images A simple but powerful method is to align the two images and subtract them
Trang 7Digital Image Processing Image Enhancement
Histogram Processing
« Histogram of a Digital Image : represents the relative frequency of occurrence of
the various gray levels in the image The histogram gives an estimate of the
probability of occurrence of each gray level
« Histogram Equalization : The goal is to obtain a uniform histogram for the output
image Consider an image pixel value u20 to be a random variable with a
continuous pdf p(w) andcdf F (6)=P[u <6] Then the random variable
will be uniformly distributed over (0,1)
(Proof) From Eq (3.2.1), the derivative of v with respect to wu is
du Substituting Eq (3.2.2) into the relation of p,(v) and p,(u):
Trang 8
(Implementation of histogram equalization on digital image)
Suppose the input uw hasa histogram A(x,), 7=0,1, -,2—1 Then we obtain
Fig 3.2.5 Histogram equalization transformation
Trang 9Image Enhancement
Digital Image Processing
(Example) Histogram equalization for the given histogram A(u) of a 3-bit image
Fig 3.2.6 Histogram equalization (a) original image, (b) original histogram (x-axis:
[0,255], y-axis: [0, 255]), (c) equalized image, (d) equalized histogram
Trang 10
« Histogram Specification : Suppose the random variable ¿>0 with pdf p,(w)
is to be transformed to v2=0 such that it has a specified pdf p,(v) For this to be
true, we define a uniform random variable
Fig 3.2.7 Histogram specification
Trang 11
(Example) Histogram specification for the given histograms (pdf) p,(w) and p.(v) of a 2-bit ima
Trang 12
3.3 Spatial Operations
Smoothing
¢« Smoothing filters are used for blurring and for noise reduction Blurring is used in
preprocessing steps, such as removal of small details from an image prior to (large)
object extraction, and bridging of small gaps in lines or curves
Spatial Averaging
¢ Each pixel is replaced by a weighted average of its neighborhood pixels, that 1s,
vữứn,n)= 3S a(k,l)y(m—k,n—]) (3.3.1)
(kJ)
where y(m,n) and v(m,n) are the input and output images, respectively, W is
a suitably chosen window, and a(k,/) are the filter weights {a(k,/)} is an
impulse response called spatial mask A common class of spatial averaging filters
has all equal weights, giving
l
we (LJ
where a(k,/)=1/N, and N,, is the number of pixels in the window W Fig
3.3.1 shows some spatial averaging masks
Trang 13Digital Image Processing Image Enhancement
Fig 3.3.1 Spatial averaging masks
Spatial averaging is used for noise smoothing, low-pass filtering, and sub-sampling
of images Suppose the observed image ts given as
where 1(m,n) is white noise with zero mean and variance O° Then the spatial
average of Eq (3.3.3) yields
(tlie
4
where T[Ún,m) is the spatial average of †J(m.n) It can be shown that TJm,n) has
Zzcro mean and varlance ỞØ ` =Ø”/N,, that ¡s, the noise power is reduced by a
factor equal to the number of pixels in the window W
Trang 14Fig 3.3.3 (a) Original image, (b) — (d) results of spatial filtering
with a mask of Fig 3.3.1 (a) —(c)
Trang 15Digital Image Processing Image Enhancement
Median Filtering
The input pixel is replaced by the median of the pixels contained in a window W
around the center pixel, that 1s,
v(m, n) = median { y(m—k,n—-1), (k, lye W} (3.3.5)
If N, is even, then the median is taken as the average of the two values in the
middle
Example 3
Let { y(m)} ={2,3,8,4,2} and W =[-1,0,1] The median filter output is given by
v(0)=2 (boundary value), v(1) = median} 2,3,8} = 3 v(2) = median} 3,8,4} = 4, v(3) = median{S.4.2} = 4 v(4) =2 (boundary value)
Hence {v(m)}= {2,3,4,4,2} If W contains an even number of pixels — for
example, W =[-1,0,1,2] — then v(0)=2, v(1l)=3, v(2) =median{2,3.8,4} =3.5,
v(3) = median{3,8,4,2} = 3.5, and v(4)=2 gives {v(m)} = {2,3,3.5,3.5,2}
Trang 16
Properties of median filter
1 Itis a nonlinear filter, that is,
median x(m) + y(m)} # median x(m)} + median y(m)}
2 It reduces impulsive noise well and also preserves edges well
Fig 3.3.5 (a) Original image, (b) image with binary noise (-128 and 128 for 10 %),
(c) averaging with 3x3 mask, and (d) 3x3 median filtered image
Trang 17Digital Image Processing Image Enhancement
Sharpening (Crispening)
e« Psychophysical experiments indicate that a photograph or visual signal with
accentuated or crispened edges is often more subjectively pleasing than exact
photometric reproduction
«Ắ Unsharp Masking : The unsharp masking technique is used commonly in the
printing industry for crispening the edges A signal proportional to the unsharp, or
low-pass filtered, version of the image is subtracted from the image This is
equivalent to adding the gradient, or a high-pass signal, to the image (See Fig
3.3.7) The unsharp masking operation can be represented by
v(m.n) =(A +1)ju(m,n)—Ah,,u(m.n)}, A>O
=u(m,n)+Alu(m,n)—h,,u(m,n)] (3.3.6)
=u(m,n)+Ah,,u(m,n)
where h,, and h,, mean low-pass and high-pass filters, respectively The
constant A is typically chosen as 0.25 ~ 0.33 Eq (3.3.6) also called high-boost or
high-frequency-emphasis filtering
Trang 19Digital Image Processing Image Enhancement
« Statistical Differencing : The statistical differencing, suggested by Wallis,
forces the enhanced image to a form with desired mean and standard deviation The
operation is defined by
oO
v(m,n) G.x) £ữÐ [w(m.m) — H(m.n)]+[ mu +(1— B)H(m.n)]} — ( )
where O(m,n) and H(m,m) represent local mean and standard deviation, oO,
and m, denote desired mean and standard deviation, @ is a gain factor that
prevents overly large output values when O(m,n) is small, and B is a factor
controlling the ratio of the edge to background intensities The constant O,, m d # 3
œ,and are typically chosen as 8.5, 128, 1/6, and 0,1
Fig 3.3.11 (a)(c) Original image, (b)(d) images after statistical differencing operation
Trang 20as
where i(m,n) represents the illumination and r(m,n) represents the reflectance
Assumption : i(m,n) 1s primary contributor to the dynamic range, varying slowly
r(m,n) is primary contributor to local contrast, varying rapidly
To separate i(m,n) from r(m,n), a logarithmic operation is applied to Eq (3.3.8)
logu(m,n) = logi(m,n) + logr(m,n) (3.3.9)
Low-pass filtering logu(m,n) — logi(m,n) High-pass filtering logu(m,n) — logr(m,n)
Trang 21Digital Image Processing Image Enhancement
logi(m,n) is attenuated to reduce the dynamic range while logr(m,n) is emphasized to increase the local contrast The processed logi(m,n) and
logr(m,n) are then combined and the result is exponentiated to get back to the
Trang 22
Zooming (Interpolation)
« Various interpolation techniques can be used in changing the size of a digital image
to improve its appearance when viewed on a display device
« Digital zooming can be performed by using a continuous interpolator which reconstructs a continuous signal from samples This operation is described in Fig
Fig 3.3.14 Description of digital zooming by continuous interpolator
The continuous signal interpolated 1s given as
where A (x) denotes a continuous interpolation function
Trang 23Digital Image Processing Image Enhancement
1 Sync-Function Interpolator (not spatially limited):
sin 70x 7x
The above interpolation functions are shown in Fig 3.3.15
Trang 24e L:1 Interpolator
Based on the theory of digital signal processing, the L:1 interpolator which
increases sampling rate by L consists of upsampler, low-pass filter, and amplifier
with gain of L It is shown in Fig 3.3.16
Fig 3.3.16 Block diagram of L:1 interpolator
Trang 25Digital Image Processing Image Enhancement
The upsampler produces a sequence
(m) u(m/L), if m is integer multiple of LZ
m)=
=u([m/ L]) Then the output sequence v(m) can be written as
v(m) = L¥ h(k) y(m—k) = LY h(k)u({(m— k)/ L)) (3.3.13)
Where the interpolation filter A(k) in general is a symmetric LPF and }{A(k)=1
For example, any QMF filter can be selected as a good interpolation filter
Relation between continuous interpolator and L:1 interpolator
Setting x =m/ L, the Eq (3.3.10) becomes
Trang 26The decimator sequence v(m) can be written as
Fig 3.3.18 Results by 2:1 Interpolators (a) square, (b) triangular,
(c) bell, and (d) cubic B-spline
Trang 27Digital Image Processing Image Enhancement
V (k,l)
« Image enhancement by transform filtering
——+» transformation }+——% operations +=} _ transformation }———_»
Fig 3.4.1 Image enhancement by transform filtering