ee 583 lecture06
TRANSCRIPT
-
7/25/2019 EE 583 Lecture06
1/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 1(PR3.1): Exponentials of the form e- r2, a positive constant, are
useful for constructing smooth gray-level transformation functions. Construct thetransformation functions having the general shapes shown in the following
figures. The constants shown are input parameters, and your proposed
transformations must include them in their specif ications.
A
A/2
L0
s=T(r)
r
(a)
B
B/2
L0
s=T(r)
r
(b)
D
C
L0
s=T(r)
r
(c)
(a)General form of the funct ion :2
)( rAerTs a2/
20 AAe
L aIn Figure (a): solving for :2
0
2
0
/693.0
693.0)5.0ln(
L
L
a
a
Then:2
20
69 3.0
)(
rL
AerTs
-
7/25/2019 EE 583 Lecture06
2/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 1(PR3.1):
B
B/2
L0
s=T(r)
r
(b)
(b) General form of the function:
2 2
1
r r
s T( r ) B Be B( e )
a a
In Figure (b): Then:
2
0
2
0
/693.0
693.0)5.0ln(
L
L
a
a
)1()(
2
20
69 3.0r
LeBrTs
2/)1(20 BeB
L a
(c) General form of the function:
D
C
L0
s=T(r)
r
(c)
CeCDrTsr
L
)1)(()(
2
20
693.0
-
7/25/2019 EE 583 Lecture06
3/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 2(PR3.3): Propose a set of gray-level-sl icing transformations
capable of producing all the individual bi t planes of an 8-bit monochromeimage.
For Bi t plane 7 (MSB): the following
function can be wri tten
otherwise
rforrT
0
2255)(
7
For Bi t plane 6:
otherwise
rforrT0
)2,mod(2255)(76
For Bi t plane 5:
otherwise
rforrT
0
)2,mod(2255)(
65
Consider mod(x,y)to be the modular division resul ting the remainder of the integer
division x/y.
-
7/25/2019 EE 583 Lecture06
4/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 2(PR3.3):
For Bi t plane 4:
otherwiserforrT
0)2,mod(2255)(
54
For Bi t plane 3:
otherwise
rforrT
0
)2,mod(2255)(
43
For Bi t plane 2:
otherwiserforrT
0)2,mod(2255)(
32
For Bi t plane 1:
otherwise
rforrT
0
)2,mod(2255)(
21
For Bi t plane 0:
otherwiserforrT
0)2,mod(2255)(
10
-
7/25/2019 EE 583 Lecture06
5/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
0 50 100 150 200 2500
50
100
150
200
250
Image Enhancement in the Spatial Domain Example 2(PR3.3):
Consider Bi t plane 6:6 7255 2 mod( , 2 )
( )0
for rT r
otherwise
r
s
s=T(r)
250=11001110
31=00011111 111=01101111
190=10111110
Note that al l the 1s corresponding to bit
6 are scaled to 255 and al l the bits
corresponding to 0s are scaled down to
0.
-
7/25/2019 EE 583 Lecture06
6/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 3(PR3.4): a) What effect would setting to zero the lower-order bit
planes have on the histogram of an image in general? b) What would be the effect on the histogram if we set to zero the higher-
order bit planes instead?
Al l the bits included
a) Removing the low order bit planes would mean the loss of some high frequency detail s.
Fur thermore the image histogram wil l be more sparseas compared with the all 8-bit
plane case.
0 50 100 150 200 250
0
200
400
600
800
1000
0 50 100 150 200 250
0
500
1000
1500
2000
2 of the LSBs removed
This is because, there wil l be no component r epresenting intermediate pixel values
such as 1,2,3,4, 5, 6,7and 9,10,11,12,13,14,15 etc. Instead there wil l be 0and 8and 16 etc.
This would cause the height some of the remaining histogram peaks to increase in general .
Typicall y, less variabil i ty in gray level values wil l reduce contrast.
-
7/25/2019 EE 583 Lecture06
7/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 3(PR3.4): b) What would be the eff ect on the histogram if we set
to zero the higher-order bit planes instead?
Al l the bits included
b) Removing the high order bit planes would mean the loss of some very
important DC components away from the image.
0 50 100 150 200 250
0
200
400
600
800
1000
MSB removed0 50 100 150 200 250
0
200
400
600
800
1000
1200
The meaning of this is that the image is much darkerand a lot of
the low f requencycomponents wil l be lost.
-
7/25/2019 EE 583 Lecture06
8/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 4(PR3.6): Suppose that a digi tal image is subjected to histogram
equal ization . Show that a second pass of hi stogram equal ization wi l l produceexactl y the same resul t as the first pass?
Let nbe the total number of pixels and let nrjbe the number of pixels in the input image with
in tensity valuerj. Then, the histogram equalization tr ansformation i s:
Since every pixel (and no others) wi th value rkis mapped to value sk, it follows that nsk= nrk
. A
second pass of h istogram equal ization would produce values vkaccording
to the transformation:
k
j
r
k
j
r
kk j
j
nnn
n
rTs00
1
)(
thennnbutn
n
sTv jjj
rs
k
j
s
kk ,,)(0
k
k
j
r
kk sn
nsTv
j 0
)(
Which shows that a second pass of histogram equal ization would yield the same resul t
as the fi rst pass.
-
7/25/2019 EE 583 Lecture06
9/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 4(PR3.6):Given an image, the fol lowing histograms and CDF (T(r) graphs can
be obtained.
0 50 100 150 200 250
0
1000
2000
3000
4000
5000
6000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 50 100 150 200 250
0
1000
2000
3000
4000
5000
6000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Histogram of the fi rst pass
H istogram of the 2nd pass
(~uni formly distributed)
T(r )=CDF of the fir st pass T(r )=CDF of the 2nd pass
(~identity transformation)
Note that the I denti ty Transformation does notchange the histogram of the input image
-
7/25/2019 EE 583 Lecture06
10/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 6(PR3.22): The three images shown below were blur red using the square
averaging masks of sizes n=23, 25 and 45 respectively. The vertical bars on the lower partof (a) and (c) are blur red, but clear separation exists between them. However, the bars
have merged in in image (b), in spite of the fact that the mask that produced the image is
signi f icantly smaller than the mask produced image (c).Explain this.
(Note that the vertical bars are 5 pixels wide and 20 pixels apart.)
(a) (b) (c)Original image
-
7/25/2019 EE 583 Lecture06
11/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 6(PR3.22):
Note that the vertical bars are 5 pixels wide and 20 pixels apart.
(a) (b) (c)
The reason why the mask wi th size n=25 producing merged uniform region around the bars is
because of the sizes of the bars and the separation of the bars in the hor izontal dir ection. The
width of each bar is 5 pixels and each bar is separated by 20 pixels.
I n such an environment as the mask moves in the hor izontal dir ection there wil l be 5 black and
20 light gray pixels in each r ow at a time. Th is wil l provide the same average value for each pixel
in the region producing a merged unif orm gray level.
However thi s wil l not be the same in 23 and 45 pixel masks!!
-
7/25/2019 EE 583 Lecture06
12/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 7(PR3.24): I n a given application an averaging mask is applied to input
images to reduce noise, and then a Laplacian mask is applied to enhance small detai ls.Would the resul t be the same if the order of these operations were reversed?
Laplacian operation and averaging can be expressed by the fol lowing 3x3 masks:
),(4)1,()1,(),1(),1(),( yxfyxfyxfyxfyxfyxgLaplacian
9
1
1( , )
9 i
i
Averaging h x y f
Both of the two operators are mul tiplying the pixels in a 3x3 neighborhood with constant
numbers and perform the addition. Therefore, these operations are li near operations.
The order of two linear operations does not matter. The resul t would be same in any order.
0 1 0
1 -4 1
0 1 0
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9
Laplacian MaskAveraging Mask
-
7/25/2019 EE 583 Lecture06
13/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Frequency Domain Example 8(PR3.25) :Show that the Laplacian operation i s isotropic (invar iant to
rotation). You wil l need the foll owing equations relating coordinates after axis rotationby an angle .
Laplacian operator is defined as:
I f we show that the r ight sides of the first 2 equations are equal than the Laplacian operationis rotation invar iant.
For the rotated Laplacian operator :
Given that:
qq
qq
cossin
sincos
yxy
yxx
We start wi th,
-
7/25/2019 EE 583 Lecture06
14/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Frequency Domain Example 8(PR3.25 ):
Taking the parti al derivative of th is expression again wi th r espect to x yields:
Repeat the same operation f or y:
Taking the parti al derivative of th is expression again wi th r espect to yyields:
Adding the 2 expressions for the second der ivatives:
Both sides are equal, Hence Laplacian i s rotational invari ant.
-
7/25/2019 EE 583 Lecture06
15/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 9(PR4.7): What is the source of nearl y per iodic bright points in the
hor izontal axi s of the spectrum in the following f igur e.
The near ly per iodic bri ght points in the frequency spectrum corr esponds to the peri odic barsas well as
the repeating boxes, letters and cir cles in the hor izontal dir ection.
l
-
7/25/2019 EE 583 Lecture06
16/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 10(PR4.6) -a): Prove the validity of the foll owing Equation.
TransformFourierthedenotesNvMuFyxf yx [.],)2/,2/(])1)(,([
1 12
0 0
1 M N j (ux / M vy / N )
x y
F( u,v ) f ( x, y )eMN
1j( x y ) x y j( x y )e ( ) e cos( ( x y )) j sin( ( x y ))
1 12 2 2
0 0
12 2
M Nj (( u M / ) x / M ( v N / ) y / N )
x y
F( u M / ,v N / ) f ( x, y )e
MN
1 12 1 2 1 2
0 0
1 M N j (( ux / M / x ) ( vy / N / y ))
x y
f ( x, y )eMN
)//(2)//(2)())2/1/()2/1/((2 )1( NvyMuxjyxNvyMuxjyxjyNvyxMuxj eeee
always zero
1 or -1depending on the addition of x+y. I f (x+y) is even then 1, otherwise -1.
1 12
0 0
11
M Nx y j ( ux / M vy / N )
x y
f ( x, y )( ) e
MN
EE 583 Di i l I P i
-
7/25/2019 EE 583 Lecture06
17/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 10(PR4.6) -b): Prove the validity of the following 2 Equations.
),(),( 00)//(2 00 vvuuFeyxf NyvMxuj
)//(21
0
1
0
)//(2)//(2 0000 ),(1
]),([ NvyMuxjM
x
N
y
NyvMxujNyvMxujeeyxf
MNeyxf
)//(2
0000),(),(
NvyMuxjevuFyyxxf
Simi lar ly, it can be shown that : ),(]),([ 00)//(2 00 yyxxfevuF NvyMuxj
Thi s is the Translation property of the 2D Four ier transform:
When x0=u0=M /2 and x0=u0=N/2, then )2/,2/()1)(,( NvMuFyxf yx
vuvuFNyMxf )1)(,()2/,2/(
1
0
1
0
)/][/]([2 00),(1 M
x
N
y
NyvvMxuujeyxf
MN
),( 00 vvuuF
EE 583 Di it l I P i
-
7/25/2019 EE 583 Lecture06
18/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 11(PR4.9): Consider the images shown below. The image on the r ight i s
obtained by (a) mult iplying the image on the lef t by (-1)x+y
; (b) computing the DFT; (c)taking the complex conjugate of the transform; (d) computing the inverse DFT; and
(e) mul tiplying the real part of the resul t by (-1)x+y. Explain (mathematically) why the
image on the right appears as it does.
The complex conjugate simply changes j toj in the inverse tr ansform, so
the image on the r ight is given by:
1
0
1
0
)//(2),()*],([M
u
N
v
NvyMuxjevuFvuF
Which simply mir rors f(x,y) about the origin, thus producing the image on
the right
1
0
1
0
)/)(/)((2),(M
u
N
v
NyvMxujevuF
),( yxf
EE 583 Di it l I P i
http://localhost/Hasan%20Demirel/Desktop/EE%20583/clear%0d%0ax=imread('DIP.jpg');%20x=double(x);%20y=x;%0d%0afx=fft2(x);%0d%0aifx=ifft2(conj(fx));%0d%0aimshow(ifx,%5b%5d);%0d%0a%0d%0a -
7/25/2019 EE 583 Lecture06
19/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 12(PR4.14): Suppose that you form a low pass fi l ter that averages the
four immediate neighbors of a poin t (x,y), but excludes the point itself . (a) F ind the equivalent f il ter H (u,v) in the fr equency domain .
(b) Show that H (u,v) is a lowpass fi l ter.
a) The spatial average is given by:
Then, using the following property:
Where the H(u ,v) is the f il ter function. We get the foll owing transfer function:
)//(2
0000),(),(
NvyMuxjevuFyyxxf
EE 583 Di it l I P i
-
7/25/2019 EE 583 Lecture06
20/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain
a) The H(u,v) Fil ter function can be centered by:
Example 12(PR4.14): Suppose that you form a low pass fi l ter that averages the
four immediate neighbors of a poin t (x,y), but excludes the point itself . (a) F ind the equivalent f il ter H (u,v) in the fr equency domain .
(b) Show that H (u,v) is a lowpass fi l ter.
b)Consider one variable for convenience. As u ranges from 0 to M , the value of cos(2[u-M/2]/M)starts at -1, peaks at 1 when u = M /2 (the center of the fi lter ) and then decreases to -1 again when u = M .
Thus, we see that the ampli tude of the fi lter decreases as a function of distance from the ori gin of the
centered fi l ter, which is the character istic of a lowpass fi lter.
A simil ar argument is easil y carr ied out when consider ing both vari ables simul taneously.
EE 583 Di it l I P i
-
7/25/2019 EE 583 Lecture06
21/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 8-PR4.19: Deri ve the frequency domain f il ter that corresponds to the
Laplacian operator in the spatial domain.
Consider theLaplacian mask given. Then,
Where
The H(u,v) F il ter function can be centered by:
EE 583 Di it l I P i
-
7/25/2019 EE 583 Lecture06
22/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image Enhancement in the Spatial Domain Example 8-PR4.22: The two four ier spectra shown are of the same image. The spectrum
of the left corresponds to the ori ginal image, and the spectrum on the ri ght was obtained after theimage was padded wi th zeros.
(a) Explain the diff erence of the overall contrast.
(b) Explain the signi fi cant increase in signal strength along the vertical and the hor izontal axes of
the spectrum shown on the right.
(a)Padding with zero increases the size but r educes the average
gray level of image. The average gray level of the padded image is
less than the original image. F(0,0) in the padded image is less than
F (0,0) of the original image.Al l the others away fr om the or igin are
less in the padded image than the original image. Th is produces a
nar rower range of values hence a lower contrast spectrum i n the
padded image.
(b)Padding with 0s introduces significant discontinu iti es at the bordersof the original image. Thi s
process in troduces strong hor izontal and vertical edgeswhere the image ends abruptly and then continues
with o values. These sharp transit ions correspond to the strength of the spectrum along the hori zontal and
verti cal axes.
EE 583: Digital Image Processing
-
7/25/2019 EE 583 Lecture06
23/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image RestorationRestoration in the presence of Noise: Only-Spatial Filtering
Example 1-PR5.10: Given the two subimages below. The sub image on theleft i s the resul t of using ari thmetic mean f il ter of size 3x3. The other
subimage is the resul t of using the geometr ic mean f i l ter of the same size.
a) Why the subimage obtained with geometr ic f il ter ing is less blur red. Hint you
can start your analysis with 1-D step edge profi le of the image.
b) Explain why the black components on the ri ght image are thicker.
a) Lets consider the mathematical expressions of the ari thmetic and geometr ic
mean fi l ters:
xySts
tsgmn
yxf,
),(1
),( mn
Sts xy
tsgyxf
1
,
),(),(
EE 583: Digital Image Processing
-
7/25/2019 EE 583 Lecture06
24/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image RestorationRestoration in the presence of Noise: Only-Spatial Filtering
Example 1-PR5.10 :
a) I f we take a rough estimate of 1-D
Step function profi le before the fi lter ing:
xySts
tsg
mn
yxf,
),(1
),(
mn
Sts xy
tsgyxf
1
,
),(),(
6 6 6 6 0 0 6 6 6 6
Before fi lteri ng:
After fil tering:
6 6 6 4 2 2 4 6 6 6
Ar ithmetic mean fi ltering:
6 6 6 6 0 0 6 6 6 6
Before fi lteri ng:
After fi ltering:
6 6 6 0 0 0 0 6 6 6
Geometr ic mean fi l ter ing:
EE 583: Digital Image Processing
-
7/25/2019 EE 583 Lecture06
25/25
EE-583: Digital Image Processing
Prepared By:Dr. Hasan Demirel, PhD
Image RestorationRestoration in the presence of Noise: Only-Spatial Filtering
Example 1-PR5.10 :
a) The resul ting 1-D profi les clearly indicates that the ari thmetic mean fi lter
produces smoother/blurred transition and
b) The geometri c fi lter ing increases the thicknessof the black components.
6 6 6 6 0 0 6 6 6 6
Before fi lteri ng:
After fi ltering:
6 6 6 4 2 2 4 6 6 6
Ar ithmetic mean fi ltering:
6 6 6 6 0 0 6 6 6 6
Before fi lteri ng:
After fi ltering:
6 6 6 0 0 0 0 6 6 6
Geometr ic mean fi l ter ing: