Upload
adnkam
View
340
Download
9
Embed Size (px)
Citation preview
Digital Image ProcessingChapter 3:
Image Enhancement in the Spatial Domain
15 June 2007
Digital Image ProcessingChapter 3:
Image Enhancement in the Spatial Domain
15 June 2007
Spatial Domain Spatial Domain
หมายถึ�งที่ตั้� งอย��หรื�อรืะนาบของ pixel ที่ปรืะกอบข� นเป�น image ซึ่�งสามารืถึรืะบ�ตั้�าแหน�งของ pixel ในความหมายของรืะยะที่างได้&
กล่�าวค�อใน spatial domain เรืาสามารืถึแที่น image ด้&วย f(x,y)เม�อ x แล่ะ y ค�อรืะยะที่างในแนวแกนตั้� งแล่ะแกนนอนว�ด้จากจ�ด้ Origin
ตั้�วอย�างที่เป�นของค��ก�นค�อ Spatial Domain ก�บ Frequency Domain
รื�ปภาพใน Spatial Domain ค�อรื�ปภาพที่อย��ในรืะนาบ xy ที่เรืาเห+นก�นตั้ามปกตั้, ใน Domain น เรืาใช้&รืะยะที่างในการืก�าหนด้ตั้�าแหน�ง
เม�อแปล่งภาพโด้ยใช้& Fourier Transform ความหมายของรืะยะที่างจะหายไป แตั้�จะเก,ด้ความหมายในเช้,งความถึข� นมาแที่น ซึ่�งข&อม�ล่น จะอย��ใน Frequencydomain
Image EnhancementImage Enhancement
Image Enhancement หมายถึ�งการืปรื�บปรื�งภาพให&เหมาะสมก�บงานเฉพาะที่างด้&านตั้�างๆ เช้�นการืที่�าให&ภาพช้�ด้เจนข� น (ในสายตั้ามน�ษย2) ตั้�วอย�าง
หมายเหตั้�: ว,ธีการืปรื�บปรื�งภาพที่เหมาะส�าหรื�บงานอย�างหน�งไม�จ�าเป�นตั้&องเหมาะสมก�บงานอกอย�างหน�งเสมอไป
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Image Enhancement ExampleImage Enhancement Example
ภาพตั้� งตั้&น ภาพที่ปรื�บปรื�งแล่&วโด้ยใช้& Gamma correction
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
หมายถึ�งการืปรื�บปรื�งภาพโด้ยใช้&กรืะบวนการืที่กรืะที่�าใน Spatial domain แล่ะให&ผล่ล่�พธี2ออกมาใน Spatial domain เช้�นก�น กล่�าวค�อ เรืาสามารืถึเขยนส�ตั้รืในรื�ป
Image Enhancement in the Spatial DomainImage Enhancement in the Spatial Domain
( , ) ( , )g x y T f x y
เม�อ f(x,y) ค�อภาพตั้� งตั้&น, g(x,y) ค�อภาพผล่ล่�พธี2 แล่ะ T[ ] ค�อ Function ที่ถึ�กก�าหนด้ในพ� นที่รือบๆจ�ด้ (x,y)
หมายเหตั้�: T[ ] อาจจะรื�บ input เป�นค�า pixel ที่ตั้�าแหน�ง (x,y) อย�างเด้ยวหรื�อ input จะเป�นค�า pixel ใน Neighbors ของจ�ด้ (x,y) ขนาด้ใด้ๆก+ได้&ตั้ามแตั้�ล่�กษณะของ Function น� นๆเช้�น การืปรื�บความสว�างของภาพ ม input เป�นค�าของ pixel (x,y) อย�างเด้ยว การืที่�าภาพเบล่อโด้ยใช้& smoothing filter ตั้&องใช้& input จาก pixel หล่ายๆ pixel รือบๆจ�ด้ (x,y)
Types of Image Enhancement in the Spatial DomainTypes of Image Enhancement in the Spatial Domain
- Single pixel methods- Gray level transformations Example
- Historgram equalization- Contrast stretching
- Arithmetic/logic operations Examples
- Image subtraction- Image averaging
- Multiple pixel methodsExamples
Spatial filtering - Smoothing filters- Sharpening filters
Gray Level TransformationGray Level Transformation
รื�ปแบบ: เป�นการืแปล่ง intensity ของภาพตั้� งตั้&นไปเป�น intensity ของภาพผล่ล่�พธี2โด้ยใช้& function:
( )s T r
โด้ย r ค�อ input intensity แล่ะ s ค�อ output intensity
ตั้�วอย�าง : Contrast enhancement
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Image NegativeImage Negative
ด้�า ขาว
ขาว
ด้�า
Input intensity
Out
put i
nten
sity
Originaldigital
mammogram
1s L r
L = จ�านวนรืะด้�บของสเที่า
0 L-1
L-1
Negativedigital
mammogram
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Log TransformationsLog Transformations
Fourierspectrum
Log Tr. ofFourier
spectrum
log( 1)s c r Application
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Power-Law TransformationsPower-Law Transformations
s cr
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Power-Law Transformations : Power-Law Transformations : Gamma Correction ApplicationGamma Correction Application
ภาพที่อยากให&เป�น ภาพที่แสด้งที่
Monitorโด้ยตั้รืง
เม�อปรื�บGamma
correction
ภาพที่แสด้งที่Monitorภายหล่�ง
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Power-Law Transformations : Power-Law Transformations : Gamma Correction ApplicationGamma Correction Application
ภาพ MRI ที่ผ�าน GammaCorrectionโด้ยใช้&ค�า Gammaค�าตั้�างๆ
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Power-Law Transformations : Power-Law Transformations : Gamma Correction ApplicationGamma Correction Application
ภาพถึ�ายที่างอากาศที่ผ�าน GammaCorrectionโด้ยใช้&ค�า Gammaค�าตั้�างๆ
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Contrast StretchingContrast Stretching
Before contrast enhancement
After
Contrast หมายถึ�งความแตั้กตั้�างรืะหว�างสที่ม�ด้ที่ส�ด้ในภาพก�บสที่สว�างที่ส�ด้ในภาพ
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
How to know where the contrast is enhanced ? How to know where the contrast is enhanced ?
ด้�ที่ Slope ของ T(r)- ถึ&า Slope > 1 Contrast เพ,ม- ถึ&า Slope < 1 Contrast ล่ด้ล่ง- ถึ&า Slope = 1 Contrast คงที่
r
s
r แคบๆ ได้& s กว&างๆ แสด้งว�า Contrast เพ,ม
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Gray Level SlicingGray Level Slicing
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Bit-plane SlicingBit-plane Slicing
Bit 7 Bit 6
Bit 2 Bit 1
Bit
5
Bit
3
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
HistogramHistogram
Histogram หมายถึ�งกรืาฟแสด้งความถึของปรืะช้ากรืในช้�วงตั้�างๆ
0
2
4
6
8
10
A B+ B C+ C D+ D F
จำ��นวนนศ.
เกรืด้ว,ช้า 178 xxx
Histogram of an ImageHistogram of an Image
ภาพที่ม�ด้ จะม histogramกองอย��ไปที่างซึ่&าย
ภาพที่สว�าง จะม histogramกองอย��ไปที่างขวา
( )k kh r n
จ�านว
น pi
xel
จ�านว
น pi
xel
หมายถึ�งเป�นกรืาฟที่แสด้งจ�านวน pixel ของส หรื�อintensity ค�าตั้�างๆ
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram of an Image (cont.)Histogram of an Image (cont.)
ภาพที่ low contrast จะม histogram กรืะจ�กก�นอย��ในช้�วงแคบๆ
ภาพที่ high contrast จะม histogram กรืะจายก�นอย��ในช้�วงกว&างๆ
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram ProcessingHistogram Processing
หมายถึ�งกรืะบวนการืปรื�บปรื�ง intensity ของรื�ปภาพเพ�อให&ได้& histogram ที่มล่�กษณะตั้ามตั้&องการื
- Histogram equalization
- Histogram matching
เป�นการืที่�าให& histogram กรืะจายก�นอย�างสม�าเสมอตั้ล่อด้
เป�นการืที่�าให& histogram มล่�กษณะเหม�อนกรืาฟที่ก�าหนด้ไว&
Monotonically Increasing FunctionMonotonically Increasing Function
หมายถึ�ง Function ที่เม�อ r เพ,มข� นแล่&ว T(r) จะมค�าเพ,มข� นหรื�อคงที่เที่�าน� นไม�มการืล่ด้ล่ง
)(rTs
Histogram processing จะเป�น function ที่มรื�ปแบบด้�งน
1. เป�น Monotonically increasing function
2. 10for 1)(0 rrT
Probability Density FunctionProbability Density Function
แล่ะให&ความส�มพ�นธี2รืะหว�าง s แล่ะ r เป�น
Histogram จะมความหมายใกล่&เคยงก�บ Probability Density Function (PDF) ซึ่�งแสด้งถึ�งค�าความหนาแน�นของค�าของตั้�วแปรืค�าตั้�างๆ
ให& s แล่ะ r เป�น Random variables ที่ม PDF เป�น ps(s) แล่ะ pr(r ) ตั้ามล่�าด้�บ
)(rTs
จะได้&ว�า
ds
drrpsp rs )()(
r
r dwwprTs0
)()(
Histogram EqualizationHistogram Equalization
ก�าหนด้ให&
จะได้&ว�า
1)(
1)(
)(
1)(
1)()()(
0
rp
rp
dr
dwwpd
rp
drds
rpds
drrpsp
rrr
r
r
rrs
!
Histogram EqualizationHistogram Equalization
ส�ตั้รืในหน&าที่แล่&วใช้&ส�าหรื�บ Continuous PDF
ส�าหรื�บ Histogram ของ Digital Image จะใช้&ส�ตั้รื
k
j
j
k
jjrkk
N
n
rprTs
0
0
)()(
nj = the number of pixels with intensity = jN = the number of total pixels
Histogram Equalization ExampleHistogram Equalization Example
Intensity # pixels
0 20
1 5
2 25
3 10
4 15
5 5
6 10
7 10
Total 100
Accumulative Sum of Pr
20/100 = 0.2
(20+5)/100 = 0.25
(20+5+25)/100 = 0.5
(20+5+25+10)/100 = 0.6
(20+5+25+10+15)/100 = 0.75
(20+5+25+10+15+5)/100 = 0.8
(20+5+25+10+15+5+10)/100 = 0.9
(20+5+25+10+15+5+10+10)/100 = 1.0
1.0
Histogram Equalization Example (cont.)Histogram Equalization Example (cont.)
Intensity
(r)
No. of Pixels
(nj)
Acc Sum of Pr
Output value Quantized Output (s)
0 20 0.2 0.2x7 = 1.4 1
1 5 0.25 0.25*7 = 1.75 2
2 25 0.5 0.5*7 = 3.5 3
3 10 0.6 0.6*7 = 4.2 4
4 15 0.75 0.75*7 = 5.25 5
5 5 0.8 0.8*7 = 5.6 6
6 10 0.9 0.9*7 = 6.3 6
7 10 1.0 1.0x7 = 7 7
Total 100
Histogram EqualizationHistogram Equalization
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram Equalization (cont.)Histogram Equalization (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram Equalization (cont.)Histogram Equalization (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram Equalization (cont.)Histogram Equalization (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram Equalization (cont.)Histogram Equalization (cont.)
ภาพตั้� งตั้&น
ภาพหล่�งที่�า Histogram Eq.
ป8ญหาในข&อน : ภาพหล่�งการืที่�า Histogram equalization กล่ายเป�นภาพ LowContrast ไป
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram MatchingHistogram Matching : Algorithm: Algorithm
r
r dwwprTs0
)()(
หล่�กการื : จาก Histogram equalization เรืาม
ได้& ps(s) = 1
User ตั้&องการืให& output image ม PDF เป�น pz(z)เรืาสามารืถึใช้&ส�ตั้รืเด้ยวก�นน ก�บ pz(z) จะได้&
z
z duupzGv0
)()( ซึ่�งจะได้& ได้& pv(v) = 1
เน�องจาก ps(s) = pv(v) = 1 ซึ่�งเสม�อนว�า s ก�บ v เป�นตั้�วแปรืเด้ยวก�น
ด้�งน� นเรืาสามารืถึแปล่ง r ไปเป�น z ได้&จาก r T( ) s G-1( ) z
เป�นการืปรืะมวล่ผล่ภาพเพ�อให&ได้& Histogram ของภาพเป�นไปตั้ามกรืาฟที่ตั้&องการื
Histogram Matching : Algorithm (cont.)Histogram Matching : Algorithm (cont.)
s = T(r) v = G(z)
z = G-1(v)
1
2
3
4
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram Matching ExampleHistogram Matching Example
Intensity
( s )
# pixels
0 20
1 5
2 25
3 10
4 15
5 5
6 10
7 10
Total 100
Histogram ของ input image เป�นด้�งน
Intensity ( z )
# pixels
0 5
1 10
2 15
3 20
4 20
5 15
6 10
7 5
Total 100
ตั้&องการืให& Histogram ของ output image เป�นด้�งน โจที่ย2ตั้�วอย�าง
User เป�นผ�&ก�าหนด้ข&อม�ล่ตั้� งตั้&น
r (nj) Pr s
0 20 0.2 1
1 5 0.25 2
2 25 0.5 3
3 10 0.6 4
4 15 0.75 5
5 5 0.8 6
6 10 0.9 6
7 10 1.0 7
Histogram Matching Example Histogram Matching Example (cont.)(cont.)
1. ที่�า Histogram Equalization ที่� งสองตั้ารืาง
z (nj) Pz v
0 5 0.05 0
1 10 0.15 1
2 15 0.3 2
3 20 0.5 4
4 20 0.7 5
5 15 0.85 6
6 10 0.95 7
7 5 1.0 7
sk = T(rk) vk = G(zk)
r s
0 1
1 2
2 3
3 4
4 5
5 6
6 6
7 7
Histogram Matching Example Histogram Matching Example (cont.)(cont.)
2. ได้&ตั้ารืาง Map
v z
0 0
1 1
2 2
4 3
5 4
6 5
7 6
7 7
sk = T(rk) zk = G-1(vk)
r s v z
s v
ได้&เป�น
r z
0 1
1 2
2 2
3 3
4 4
5 5
6 5
7 6
z # Pixels
0 0
1 20
2 30
3 10
4 15
5 15
6 10
7 0
Actual Output Histogram
Histogram Matching Example (cont.)Histogram Matching Example (cont.)
Desired histogram
Transfer function
Actual histogram
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Histogram Matching Example (cont.)Histogram Matching Example (cont.)
Originalimage
Afterhistogram
equalization
Afterhistogram matching
Local Enhancement : Local Histogram EqualizationLocal Enhancement : Local Histogram Equalization
Concept: Perform histogram equalization in a small neighborhood
Orignal image After Hist Eq.After Local Hist Eq.In 7x7 neighborhood
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Local Enhancement : Local Enhancement : Histogram Statistic for Image EnhancementHistogram Statistic for Image Enhancement
เรืาสามารืถึน�าค�าที่างสถึ,ตั้,เช้�น Mean, Variance ของ Local area มาใช้&งานได้&
ภาพไส&หล่อด้ไฟถึ�ายโด้ยกล่&องจ�ล่ที่�ศน2อ,เล่+กตั้รือน
ม�มขวาล่�างจะมภาพไส&หล่อด้ไฟที่อย��ด้&านหล่�งซึ่�งค�อนข&างม�ด้
เรืาตั้&องการืเพ,มความสว�างให&ใส&หล่อด้ด้&านหล่�ง
ถึ&าปรื�บความสว�างที่� งภาพ แล่&วไส&หล่อด้ด้&านหน&าจะสว�างเก,นไป
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Local EnhancementLocal Enhancement
ตั้�วอย�างส�ตั้รื Local enhancement (พ,เศษเฉพาะงานน )
otherwise ),(
and when),(),( 210
yxf
MkDkMkmyxfEyxg GsGGs xyxy
Original imageLocal Variance
image Multiplication
factor
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Local EnhancementLocal Enhancement
Output image
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Logic OperationsLogic Operations
AND
OR
ได้&ผล่ล่�พธี2เป�น ROI: Region of Interest
Image maskOriginalimage
Application:ใช้&ตั้�ด้พ� นที่ที่สนใจใน Image ออกมา
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Arithmetic Operation: SubtractionArithmetic Operation: Subtraction
Error image
Application: Error measurement
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Arithmetic Operation: Subtraction (cont.)Arithmetic Operation: Subtraction (cont.)
Application: Mask mode radiography in angiography work
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Arithmetic Operation: Image AveragingArithmetic Operation: Image Averaging
Application : Noise reduction
),(),(
1yxyxg
K
การืที่�า average จะที่�าให& Varianceของ noise ล่ด้ล่ง
),(),(),( yxyxfyxg Degraded image
(noise)Image averaging
K
ii yxg
Kyxg
1
),(1
),(
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Arithmetic Operation: Image Averaging (cont.)Arithmetic Operation: Image Averaging (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Sometime we need to manipulate values obtained from neighboring pixels
Example: How can we compute an average value of pixelsin a 3x3 region center at a pixel z?
4
4
67
6
1
9
2
2
2
7
5
2
26
4
4
5
212
1
3
3
4
2
9
5
7
7
35 8222
Pixel z
Image
Basics of Spatial FilteringBasics of Spatial Filtering
4
4
67
6
1
9
2
2
2
7
5
2
26
4
4
5
212
1
3
3
4
2
9
5
7
7
35 8222
Pixel z
Step 1. Selected only needed pixels
4
67
6
9
1
3
3
4……
……
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
4
67
6
9
1
3
3
4……
……
Step 2. Multiply every pixel by 1/9 and then sum up the values
19
16
9
13
9
1
69
17
9
19
9
1
49
14
9
13
9
1
y
1 1
1
1
1
1
1
1
19
1
X
Mask orWindow orTemplate
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
Question: How to compute the 3x3 average values at every pixels?
4
4
67
6
1
9
2
2
2
7
5
2
26
4
4
5
212
1
3
3
4
2
9
5
7
7
Solution: Imagine that we havea 3x3 window that can be placedeverywhere on the image
Masking Window
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
4.3
Step 1: Move the window to the first location where we want to compute the average value and then select only pixels inside the window.
4
4
67
6
1
9
2
2
2
7
5
2
26
4
4
5
212
1
3
3
4
2
9
5
7
7
Step 2: Computethe average value
3
1
3
1
),(9
1
i j
jipy
Sub image p
Original image
4 1
9
2
2
3
2
9
7
Output image
Step 3: Place theresult at the pixelin the output image
Step 4: Move the window to the next location and go to Step 2
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
The 3x3 averaging method is one example of the mask operation or Spatial filtering.
The mask operation has the corresponding mask (sometimes called window or template).
The mask contains coefficients to be multiplied with pixelvalues.
w(2,1) w(3,1)
w(3,3)
w(2,2)
w(3,2)
w(3,2)
w(1,1)
w(1,2)
w(3,1)
Mask coefficients
1 1
1
1
1
1
1
1
19
1
Example : moving averaging
The mask of the 3x3 moving average filter has all coefficients = 1/9
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
The mask operation at each point is performed by:1. Move the reference point (center) of mask to the location to be computed 2. Compute sum of products between mask coefficients and pixels in subimage under the mask.
p(2,1)
p(3,2)p(2,2)
p(2,3)
p(2,1)
p(3,3)
p(1,1)
p(1,3)
p(3,1)
……
……
Subimage
w(2,1) w(3,1)
w(3,3)
w(2,2)
w(3,2)
w(3,2)
w(1,1)
w(1,2)
w(3,1)
Mask coefficients
N
i
M
j
jipjiwy1 1
),(),(
Mask frame
The reference pointof the mask
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
The spatial filtering on the whole image is given by:
1. Move the mask over the image at each location.
2. Compute sum of products between the mask coefficeintsand pixels inside subimage under the mask.
3. Store the results at the corresponding pixels of the output image.
4. Move the mask to the next location and go to step 2until all pixel locations have been used.
Basics of Spatial Filtering (cont.)Basics of Spatial Filtering (cont.)
Examples of Spatial Filtering Masks
Examples of the masks
Sobel operators
0 1
1
0
0
2
-1
-2
-1
-2 -1
1
0
2
0
-1
0
1
x
P
compute toy
P
compute to
1 1
1
1
1
1
1
1
19
1
3x3 moving average filter
-1 -1
-1
8
-1
-1
-1
-1
-19
1
3x3 sharpening filter
Smoothing Linear Filter : Moving AverageSmoothing Linear Filter : Moving Average
Application : noise reductionand image smoothing
Disadvantage: lose sharp details
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Smoothing Linear Filter (cont.)Smoothing Linear Filter (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Order-Statistic FiltersOrder-Statistic Filters
subimage
Original image
Moving window
Statistic parametersMean, Median, Mode, Min, Max, Etc.
Output image
Order-Statistic Filters: Median FilterOrder-Statistic Filters: Median Filter
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Sharpening Spatial FiltersSharpening Spatial Filters
There are intensity discontinuities near object edges in an image
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Laplacian Sharpening : How it worksLaplacian Sharpening : How it works
20 40 60 80 100 120 140 160 180 200
0
0.5
1
0 50 100 150 2000
0.1
0.2
0 50 100 150 200-0.05
0
0.05
Intensity profile
1st derivative
2nd derivative
p(x)
dx
dp
2
2
dx
pd
Edge
0 50 100 150 200-0.5
0
0.5
1
1.5
0 50 100 150 200-0.5
0
0.5
1
1.5
Laplacian Sharpening : How it works (cont.)Laplacian Sharpening : How it works (cont.)
2
2
10)(dx
pdxp
Laplacian sharpening results in larger intensity discontinuity near the edge.
p(x)
Laplacian Sharpening : How it works (cont.)Laplacian Sharpening : How it works (cont.)
2
2
10)(dx
pdxp
p(x)Before sharpening
After sharpening
Laplacian MasksLaplacian Masks
-1 -1
-1
8
-1
-1
-1
-1
-1
-1 0
0
4
-1
-1
0
-1
0
1 1
1
-8
1
1
1
1
1
1 0
0
-4
1
1
0
1
0
Application: Enhance edge, line, point
Disadvantage: Enhance noise
Used for estimating image Laplacian 2
2
2
22
y
P
x
PP
or
The center of the mask is positive
The center of the mask is negative
Laplacian Sharpening ExampleLaplacian Sharpening Example
p P2
P2 PP 2
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Laplacian Sharpening (cont.)Laplacian Sharpening (cont.)
PP 2Mask for
1 1
1-81
1111
-1 -1
-1
9
-1
-1
-1
-1
-1
-1 0
0
5
-1
-1
0
-1
0
1 0
0-41
1010
or
Mask forP2
or
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
Unsharp Masking and High-Boost FilteringUnsharp Masking and High-Boost Filtering
-1 -1
-1
k+8
-1
-1
-1
-1
-1
-1 0
0
k+4
-1
-1
0
-1
0
Equation:
),(),(
),(),(),(
2
2
yxPyxkP
yxPyxkPyxPhb
The center of the mask is negative
The center of the mask is positive
Unsharp Masking and High-Boost Filtering (cont.)Unsharp Masking and High-Boost Filtering (cont.)
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
First Order DerivativeFirst Order Derivative
20 40 60 80 100 120 140 160 180 2000
0.5
1
0 50 100 150 200-0.2
0
0.2
0 50 100 150 2000
0.1
0.2
Intensity profile
1st derivative
2nd derivative
p(x)
dx
dp
dx
dp
Edges
First Order Partial Derivative:First Order Partial Derivative:
Sobel operators
0 1
1
0
0
2
-1
-2
-1
-2 -1
1
0
2
0
-1
0
1x
P
compute toy
P
compute to
Px
P
y
P
First Order Partial Derivative: Image GradientFirst Order Partial Derivative: Image Gradient
22
y
P
x
PP
Gradient magnitude
A gradient image emphasizes edges(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
First Order Partial Derivative: Image GradientFirst Order Partial Derivative: Image Gradient
P
x
P
y
P
P
Image Enhancement in the Spatial Domain : Image Enhancement in the Spatial Domain : Mix things up !
+ -
A
P2
Sharpening
P
smoothB
EC
D
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.
EC
MultiplicationF
Image Enhancement in the Spatial Domain : Image Enhancement in the Spatial Domain : Mix things up !
A
G
H
PowerLaw Tr.
(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.