Upload
zoe-noble
View
46
Download
3
Embed Size (px)
DESCRIPTION
Chapter 3 Image Enhancement in the Spatial Domain. 國立雲林科技大學 資訊工程所 張傳育 (Chuan-Yu Chang ) 博士 Office: EB212 TEL: 05-5342601 ext. 4337 E-mail: [email protected] Website:MIPL.yuntech.edu.tw. Preview. - PowerPoint PPT Presentation
Citation preview
Chapter 3Image Enhancement in the Spatial Domain
國立雲林科技大學 資訊工程所張傳育 (Chuan-Yu Chang ) 博士Office: EB212TEL: 05-5342601 ext. 4337E-mail: [email protected]:MIPL.yuntech.edu.tw
2Medical Image Processing & Neural Networks Laboratory
Preview
The principal objective of enhancement is to process an image so that the result is more suitable than the original image for a specific application.
Image enhancement approaches Spatial domain methods
Based on direct manipulation of pixels in an image. Frequency domain methods
Based on modifying the Fourier transform of an image.
3Medical Image Processing & Neural Networks Laboratory
Spatial domain process willbe denoted by g(x,y)=T[f(x,y)]where f(x,y): input image g(x,y): processed image T: an operator
maskfilterkerneltemplatewindows
Background Spatial domain
Refers to the aggregate of pixels composing an image.
Operate directly on these pixels
4Medical Image Processing & Neural Networks Laboratory
Gray-Level (intensity) transformation Function s=T(r) where T is gray-level transformation function
Processing technologies: Point processing
Enhancement at any point in an image depends only on the gray level at that point.
Mask processing or filtering Use a function of the values of f in a predefined neighborhood of (x,y) to
determine the value of g at (x,y)
Background (cont.)
Contrast stretching
thresholding
5Medical Image Processing & Neural Networks Laboratory
Some basic Gray Level Transforms s = T(r) r : the gray level value before
process s: the gray level value after
process
Values of the transformation function typically are stored in a one-dimensional array and the mapping from r to s are implemented via table lookups.
Some Basic Gray Level Transforms
6Medical Image Processing & Neural Networks Laboratory
Image Negatives Reversing the intensity levels of an image Photographic Negative s=L-1-r Suited for enhancing white or gray detail embedded in dark
regions of an image
Some Basic Gray Level Transforms (cont.)
7Medical Image Processing & Neural Networks Laboratory
Log Transformations s=c log (1+r) Maps a narrow range of low gray-level values in the input
image into a wider range of output levels. To expand the values of dark pixels in an image while
compressing the higher-level values
Some Basic Gray Level Transforms (cont.)
A Fourier spectrum with values in the
range 0 to 1.5x106.
c=1, the range of values : 0 to 6.2.
8Medical Image Processing & Neural Networks Laboratory
Power-Law Transformations s=cr
s= c (r + )r
where c and ` are positive constants
Power-law curves with fractional values of r map a narrow range of dark input values into a wider range of output values, with the opposite being true for higher values of input levels.
Some Basic Gray Level Transforms (cont.)
To account for an offset
9Medical Image Processing & Neural Networks Laboratory
Some Basic Gray Level Transforms (cont.) Gamma Correction
The process used to correct this power-law response phenomena
10Medical Image Processing & Neural Networks Laboratory
Some Basic Gray Level Transforms (cont.) Example 3.1
MR image of fractured human spine Contrast
manipulation
c=1, =0.4
c=1, =0.3
c=1, =0.6
Fracturedislocation
褪色 (Washed-out)
The best enhancementin terms of contrast and discernable detail wasobtained.
11Medical Image Processing & Neural Networks Laboratory
Some Basic Gray Level Transforms (cont.)
Washed-out appearance
c=1, =3.0
c=1, =5.0
c=1, =4.0
12Medical Image Processing & Neural Networks Laboratory
Picewise-Linear Transformation FunctionPicewise-Linear Transformation Function
Some Basic Gray Level Transforms (cont.) Contrast Stretching
To increase the dynamic range of the gray levels in the image being processed.
Linear function If r1=s1 and r2=s2
Thresholding If r1=r2, s1=0 and s2=L-1
Control points
13Medical Image Processing & Neural Networks Laboratory
Picewise-Linear Transformation FunctionPicewise-Linear Transformation Function
Gray-level SlicingHighlighting a specific range of gray levels in an image.
To display a high value for all gray levels in the range of interest and a low value for all other gray levels.Brightens the desired range of gray levels but preserves the background and gray-level in the image.
Some Basic Gray Level Transforms (cont.)
14Medical Image Processing & Neural Networks Laboratory
Some Basic Gray Level Transforms (cont.) Bit-plane Slicing
Highlighting the contribution made to total image appearance by specific bits.
Separating a digital image into its bit planes is useful for analyzing the relative importance played each bit of the image. Determining the adequacy of the number of bits used to quantize
each pixel. Image compression.
15Medical Image Processing & Neural Networks Laboratory
Some Basic Gray Level Transforms (cont.) An 8-bit fractal image
16Medical Image Processing & Neural Networks Laboratory
Some Basic Gray Level Transforms (cont.) The eight bit planes of the image in Fig. 3.13
17Medical Image Processing & Neural Networks Laboratory
Histogramh(rk)= nk
rk is the kth gray-level
nk is the number of pixels in the
image having gray-level k Normalized Histogramp(rk)=nk/n
Histogram Processing
18Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.) Histogram Equalization
10)( rrTs
Assume that the transformation function T(r) satisfies the follows(a) T(r) is a single-valued and monotonically increasing(b) 0<=T(r)<=1 for 0<=r <=1
19Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.) The probability of occurrence of gray level rk in an image is
approximated by
The discrete version of the transformation function given as
A processed image is obtained by mapping each pixel with level rk in the input image into a corresponding pixel with level sk in the output image.
1,...,2,1,0
)()(
0
0
Lkn
n
rprTs
k
j
j
k
jjrkk
Histogram equalization automatically determines a transformationfunction that seeks to produce an output image that has a uniform histogram.
1,...,2,1,0)( Lkn
nrp kkr
20Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.) Example 3.3Histogram equalization
21Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.)
22Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.)
Histogram matching (Specification) Let s be a random variable with the property
Define a random variable z with the property
Assume that G(z)=T(r), therefore, that z must satisfy the condition
r
r dwwprTs0
)(
z
z dttpzG0
rTGsGz 11
(3.3-10)
(3.3-11)
(3.3-12)
23Medical Image Processing & Neural Networks Laboratory
Histogram matching (Specification) To specify the shape of the histogram that we wish the
processed image to have.
1,...,2,1,0
1,...,2,1,0)(
1,...,2,1,0)()(
1,...,2,1,0
)()(
1
1
0
0
0
LksGz
LkrTGz
LkszpzGv
Lkn
n
rprTs
kk
kk
k
k
iizkk
k
j
j
k
jjrkk
Histogram Processing (cont.)
(3.3-13)
(3.3-14)
(3.3-15)
(3.3-16)
24Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.)1. 對原圖進行 histogram equalization
2. 對給予的 histogram, 計算轉換函數 G(z)根據手繪函數 G(z) 求出每個 Zq 所對應的 vq
3. 對每個 sk ,求對應的 Zk
25Medical Image Processing & Neural Networks Laboratory
Procedure for histogram matching1. Obtain the histogram of the given image
2. Use E.q.(3.3-13) to precompute a mapped level sk for each level rk
3. Obtain the transformation function G(z) from the given pz(z) using Eq.(3.3-14)
4. Precompute zk for each value of sk using the scheme defined in Eq(3.3-17)
5. Use the value from step (2) and step (4), mapping rk to its corresponding level sk, then map level sk into the final level zk.
26Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.) Example 3.4 Comparison between histogram
equalization and histogram matching
火星的衛星影像,有大區域的深色區域,由其 histogram 觀察,會以為 histogram equalization 會有不錯的結果?
27Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.)
由於圖 3.20 中的histogram,gray level 0 及其附近有大量的值,因此根據 Eq(3.3-8) ,s0 會接近 190 。
直接以圖 (a) 進行equalization 會有褪色的感覺。
28Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.)
手繪的 histogram
手繪的 histogram 之轉換函數 G(z)
轉換後的結果
轉換後的 histogram
29Medical Image Processing & Neural Networks Laboratory
Local Enhancement
Global enhancement The pixels are modified by a transformation function based on
the gray-level content of an entire image. Local enhancement
To design transformation functions based on the gray-level distribution in the neighborhood of every pixel in the image.
Local enhancement Procedure Step 1: Define a square neighborhood Step 2: Move the center of this area from pixel by pixel
Calculate the histogram of the points in the neighborhood. Apply the histogram equalization or specification Assign new gray level to the center pixel
Step 3: Moved to an adjacent pixel location. Repeat Step 2 until end of the image
30Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.)
Example 3.5 Enhancement using local histograms
Original imageResult of global
histogram equalization
Result of local histogram equalization
31Medical Image Processing & Neural Networks Laboratory
Use of Histogram Statistics for Image Enhancement The global mean and variance
The mean is a measure of average gray level in an image The variance is a measure of average contrast in an
image. Let r denote discrete gray-levels in the range p(ri) denote the normalized histogram component
corresponding to the ith value of r. The nth moment of r is defined as
where m is the mean value of r
]1,0[ Lr
1
0
)()(L
ii
nin rpmrr
1
0
)(L
iii rprm
(3.3-18)
(3.3-19)
32Medical Image Processing & Neural Networks Laboratory
Use of Histogram Statistics for Image Enhancement
根據 (3.3-18) 及 (3.3-19)0=1, 1=0 The second moment is obtained by
(3.3-20) 為 r 的 variance 。 Standard deviation 定義為 variance 的平方根 (square root) 。
The global mean and variance are measured over an entire image and are useful primarily gross adjustments of overall intensity and contrast.
)(
)()(
2
1
0
22
r
rpmrrL
iii
(3.3-20)
33Medical Image Processing & Neural Networks Laboratory
Histogram Statistics for Image Enhancement
The local mean and variance The local mean is a measure of average gray level in
neighborhood Sxy
The variance is a measure of contrast in the neighborhood
xy
xyxyS
xy
xy
StstsSts
StststsS
rpmr
rprm
),(,
2,
2
),(,,
)(
)(
(3.3-21)
(3.3-22)
34Medical Image Processing & Neural Networks Laboratory
Example 3.6鎢絲 1( 清楚 )
鎢絲 2( 不清楚 )
35Medical Image Processing & Neural Networks Laboratory
Example 3.6
The problem is to enhance dark areas while leaving the light area as unchanged as possible. Consider the pixel as a point (x,y) as a candidate for
processing
21120
211
2
0
),(
),(
))((),(),(
,)3(
)2(
)1(
kkDk
otherwiseyxf
DkMkmifyxfEyxg
Thus
kkDkif
Dkif
Mkmif
xyxyxy
xy
xy
xy
SGGSGS
SG
GS
GS
36Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.)
對影像取 localmean average
對影像取 localstandard deviation
採用 3x3 local region
三個條件判別後的結果
白色部分為 E ,用來對原影像相乘,以得到強化的結果。
37Medical Image Processing & Neural Networks Laboratory
Histogram Processing (cont.)
38Medical Image Processing & Neural Networks Laboratory
Enhancement using Arithmetic/Logic Operations Arithmetic/Logic operations are performed on a
pixel-by-pixel basis. Arithmetic operations: subtraction, addition,
division, multiplication. Logic operations: AND, OR, NOT When dealing with logic operations on gray-scale
images, pixel values are processed as strings of binary numbers.
Enhancement using Arithmetic/Logic Operations
39Medical Image Processing & Neural Networks Laboratory
Enhancement using Arithmetic/Logic Operations (cont.)
40Medical Image Processing & Neural Networks Laboratory
Enhancement using Arithmetic/Logic Operations (cont.)
41Medical Image Processing & Neural Networks Laboratory
Image Subtraction The enhancement of difference between images
The difference between two images f(x,y) and h(x,y)
),(),(),( yxhyxfyxg
Enhancement using Arithmetic/Logic Operations (cont.)
(3.4-1)
42Medical Image Processing & Neural Networks Laboratory
Enhancement using Arithmetic/Logic Operations (cont.) Most images are displayed using 8 bits.
Thus, we expect image values not to be outside the range from 0 to 255.
The value in a difference image can range from a minimum of -255 to a maximum of 255.
How to solve this problem? Solution 1: g’(x,y)=[g(x,y)+255]/2 Solution 2:
g’(x,y)=g(x.y)-min(g(x,y))g’’(x,y)=[g’(x,y)*255]/max(g’(x,y))
43Medical Image Processing & Neural Networks Laboratory
Image averaging Noisy image g(x,y) formed by the addition of noise (x,y) to
an original image f(x,y)
Assume that at every pair of coordinates (x,y) the noise is uncorrelated and has zero average value.
Averaging K different noisy images
To reduce the noise content by adding a set of noisy images The standard deviation at any point in the average image is
),(),(),( yxyxfyxg
K
ii yxg
Kyxg
1
),(1
),(
),(1
),(yx
Kyxg
Enhancement using Arithmetic Operations (cont.)
(3.4-2)
(3.4-3)
(3.4-6)
As K increases, Eq(3.4-6) indicates that the noise of the pixel values at each location (x,y) decreases.
44Medical Image Processing & Neural Networks Laboratory
Enhancement using Arithmetic/Logic Operations (cont.) Example 3.8 Noise reduction
by image averaging The images gi(x,y) must be
registered in order to avoid the introduction of blurring and other artifacts.
(a) Image of Galaxy pair NGC 3314.
(b) Image corrupted by additive Gaussian noise with zero mean and a standard deviation of 64 gray levels.
(c-f) Result of averaging K=8, 16, 64 and 128 noisy images.
45Medical Image Processing & Neural Networks Laboratory
Enhancement using Arithmetic/Logic Operations (cont.)
In the histograms, the mean and standard deviation of the difference images decrease as K increases.
46Medical Image Processing & Neural Networks Laboratory
Basic of spatial filtering
)1,1()1,1(),1()0,1(...),()0,0(
...),1()0,1()1,1()1,1(
yxfwyxfwyxfw
yxfwyxfwR
a
as
b
bt
tysxftswyxg ),(),(),(
where a=(m-1)/2 b=(n-1)/2
If image size M×N, mask size m×n
Convolving a mask with an image
Basic of spatial filtering
47Medical Image Processing & Neural Networks Laboratory
mn
iii
mnmn
zw
zwzwzwR
1
2211 ...
9
1
992211 ...
iii zw
zwzwzwR
Basic of spatial filtering (cont.)
48Medical Image Processing & Neural Networks Laboratory
Smoothing Spatial Filter
Smoothing filters are used for blurring and for noise reduction. Smoothing Linear Filter
Sometimes are called averaging filter , lowpass filter Box filter
A spatial averaging filter in which all coefficients are equal
Weighted average Pixels are multiplied at different coefficient
9
19
1
iizR
a
as
b
bt
a
as
b
bt
tsw
tysxftswyxg
),(
),(),(),(
49Medical Image Processing & Neural Networks Laboratory
Smoothing Spatial Filter (cont.) Example 3.9
Image smoothing with masks of various sizes (a) Original image of size
500x500 (b-f) Results of
smoothing with square averaging filter masks of sizes n=3, 5, 9, 15, and 35.
50Medical Image Processing & Neural Networks Laboratory
Smoothing Spatial Filter (cont.) Spatial averaging is to blur an image for the purpose
getting a gross representation of objects of interest. The intensity of smaller objects blends with the background
and larger objects become “bloblike” and easy to detect.
51Medical Image Processing & Neural Networks Laboratory
Order-Statistic Filters Order-Statistic Filters (Nonlinear spatial filters)
Based on ordering the pixels contained in the image area encompassed by the filter. And then replacing the value of the center pixel with the value determined by the ranking result.
Median filter Particularly effective in the presence of impulse noise (salt-
pepper noise) Algorithm:
Step 1: sort the value of the pixels encompassed by the filter.Step 2: determine their median.Step 3: assign the median to the center pixel.
52Medical Image Processing & Neural Networks Laboratory
Order-Statistic Filters Max filter Min filter
53Medical Image Processing & Neural Networks Laboratory
Sharpening Spatial Filters Objectives:
To highlight fine detail in an image To enhance detail that has been blurred
The derivatives of a digital function are defined in terms of differences
First derivative Must be zero in flat segment Must be nonzero at the onset of a gray-level step or ramp Must be nonzero along ramps
)()1( xfxfx
f
54Medical Image Processing & Neural Networks Laboratory
Sharpening Spatial Filters
Second derivative Must be zero in flat areas Must be nonzero at the onset and the end of gray-level
step or ramp. Must be zero along ramps of constant slope
)(2)1()1(
)1()()()1(2
2
xfxfxf
xfxfxfxfx
f
55Medical Image Processing & Neural Networks Laboratory
Sharpening Spatial Filters (cont.)
56Medical Image Processing & Neural Networks Laboratory
Sharpening Spatial Filters (cont.) Summary
First-order derivatives generally produce thicker edges in an image.
Second-order derivatives have a stronger response to fine detail
First-order derivatives generally have a stronger response to a gray-level step
Second-order derivatives produce a double response at step changes in gray level.
57Medical Image Processing & Neural Networks Laboratory
Use of Second Derivatives for Enhancement- The Laplacian
Isotropic filter (rotation invariant) Whose response is independent of the direction of the
discontinuities in the image. Laplacian
),(4)1,()1,(),1(),1(
),(2)1,()1,(
),(2),1(),1(
2
2
2
2
2
2
2
2
22
yxfyxfyxfyxfyxff
yxfyxfyxfy
f
yxfyxfyxfx
f
y
f
x
ff
58Medical Image Processing & Neural Networks Laboratory
Use of Second Derivatives for Enhancement- The Laplacian
59Medical Image Processing & Neural Networks Laboratory
Use of Second Derivatives for Enhancement- The Laplacian Image enhancement
positiveistcoefficiencentertheif
negativeistcoefficiencentertheif
yxfyxf
yxfyxfyxg
),(),(
),(),(),(
2
2
)1,()1,(),1(),1(),(5
),(4)1,()1,(),1(),1(),(),(
yxfyxfyxfyxfyxf
yxfyxfyxfyxfyxfyxfyxg
60Medical Image Processing & Neural Networks Laboratory
Use of Second Derivatives for Enhancement- The Laplacian (cont.) Example 3.11
Imaging sharpening with the Laplacian.
61Medical Image Processing & Neural Networks Laboratory
Use of Second Derivatives for Enhancement- The Laplacian (cont.) Example 3.12
Image enhancement using a composite Laplacian mask
62Medical Image Processing & Neural Networks Laboratory
Use of Second Derivatives for Enhancement- The Laplacian (cont.) Unsharp masking and high-boost filtering
Used in publishing industry Unsharp masking: To sharpen images consist of subtracting
a blurred version of an image from the image itself.
),(),(),( yxfyxfyxf s
63Medical Image Processing & Neural Networks Laboratory
Use of Second Derivatives for Enhancement- The Laplacian (cont.) Example 3.13
Image enhancement with a high-boost filter
64Medical Image Processing & Neural Networks Laboratory
Use of First Derivatives for Enhancement -The Gradient The gradient of f at coordinates (x,y) is defined
as the two-dimensional column vector:
The magnitude of this vector is given by
y
fx
f
G
G
y
xf
2/122
2/122
)(
y
f
x
f
GG
magf
yx
f
65Medical Image Processing & Neural Networks Laboratory
Use of First Derivatives for Enhancement -The Gradient (cont.)
66Medical Image Processing & Neural Networks Laboratory
Use of First Derivatives for Enhancement -The Gradient Example 3.14
Use of the gradient for edge enhancement.
67Medical Image Processing & Neural Networks Laboratory
Chapter 3Image Enhancement in the
Spatial Domain
Chapter 3Image Enhancement in the
Spatial Domain
68Medical Image Processing & Neural Networks Laboratory
Chapter 3Image Enhancement in the
Spatial Domain
Chapter 3Image Enhancement in the
Spatial Domain