L-8, 9,10 (Digital ImageProcessing-Image Enhancement in Frequency Domain)
L-8, 9,10 (Digital ImageProcessing-Image Enhancement in Frequency Domain)
Established in 1998
Session: 2020-21
• Restoration / Enhancement
• Inverse Filtering
• Match Filtering / Pattern Detection
• Tomography
Enhancement v.s. Restoration
• Image Enhancement:
– A process which aims to improve bad images so
they will “look” better.
• Image Restoration:
– A process which aims to invert known degradation
operations applied to images.
Enhancement vs. Restoration
• “Better” visual • Remove effects of
representation sensing environment
• Subjective • Objective
Low Illumination
Optical distortions
(geometric, blurring)
Sensor distortion
(quantization, sampling,
sensor noise, spectral sensitivity,
Atmospheric attenuation
de-mosaicing)
(haze, turbulence, …)
Image Preprocessing
Enhancement Restoration
• Denoising
• Inverse filtering
Spatial Freq.
• Wiener filtering
Domain Domain
Filtering
Point operations Spatial operations
Examples
Hazing
Echo image Motion Blur
Blurred image Blurred image + additive white noise
Reconstruction as an Inverse Problem
n noise
Original image Distortion
f g Hf n
H
measurements
fˆ
Reconstruction
g Algorithm
So what is the problem?
g H 1
g n fˆ
• Typically:
– The distortion H is singular or ill-posed.
– The noise n is unknown, only its statistical
properties can be learnt.
Key point: Stat. Prior of Natural Images
likelihood prior
MAP estimation:
fˆ arg max P f g arg max P g f P f
x x
Bayesian Reconstruction (MAP)
• From amongst all possible solutions, choose the one that
maximizes the a-posteriori probability:
P(f)
measurements
P(g|f)
Image space
Bayesian Denoising
• Assume an additive noise model :
g=f + n
• A MAP estimate for the original f:
fˆ arg max P f | g
f
ˆf arg min g f 2 R f
f
data term prior term
g(x,y) = h(x,y)*f(x,y)
G(u,v)=H(u,v)F(u,v)
F(u,v)=G(u,v)/H(u,v)
Inverse Filtering (Cont.)
Two problems with the above formulation:
1. H(u,v) might be zero for some (u,v).
2. In the presence of noise the noise might be amplified:
F(u,v)=G(u,v)/H(u,v) + N(u,v)/H(u,v)
Fˆ arg min E F
F
E F HF G F
2 2
where
• Solution:
E F
2 H HF G 2F 0
*
F
*
H H (u , v ) 1 Fˆ G H
Fˆ * G
H H H (u , v ) 1 Fˆ 0
Degraded Image (echo)
F=G/H
*
H
Fˆ G
H H
*
Degraded Image (echo+noise)
*
H
Fˆ G
H H
*
• The inverse filter is C(H)= H*/(H*H+ )
• At some range of (u,v):
S(u,v)/N(u,v) < 1 noise
amplification.
18
16
14
12
10
C(H)
8 =10-3
6
0
-1 -0.5 0 0.5 1 1.5 2
H
Option 2: Prior Term
1. Natural images tend to have low energy at high frequencies
2. White noise tend to have constant energy along freq.
where
Fˆ arg min E F
F
E F HF G u 2 v 2 F 2
2
240
220
200
180
160
140
120
100
80
60
40
F
*
H
Fˆ G
H H u v
*
2 2
• This solution is known as the Wienner Filter
• Here we assume N(u,v) is constant.
• If N(u,v) is not constant:
*
H
Fˆ * G
H H u v N (u , v)
2 2
Degraded Image (echo+noise)
Wienner Filtering
Wienner Previous
Degraded Image (blurred+noise)
Inverse Filtering
Using Prior (Option 1)
Wienner Filtering
Matched Filter in Freq. Domain
• Pattern Matching:
– Finding occurrences of a particular pattern in an image.
• Pattern:
– Typically a 2D image fragment.
– Much smaller than the image.
Image Similarity Measures
• Image Similarity Measure:
– A function that assigns a nonnegative real value to two
given images.
– Small measure high similarity
– Preferable to be a metric distance (non-negative, identity,
symmetric, triangular inequality)
d( - )≥0
• Can be combined with thresholding:
1 d ( P, Q) threshold
f ( P, Q )
0 otherwise
The Matching Approach
• Scan the entire image pixel by pixel.
• For each pixel, evaluate the similarity between its local
neighborhood and the pattern.
The Euclidean Distance
as a Similarity Measure
• Given:
– k×k pattern P
– n×n image I
– kxk window of image I located at x,y - Ix,y
• For each pixel (x,y), we compute the distance:
1
d I , P x , y
2
2
E 2 I x, y P
k
k 1
1
2 I x i , y j P i , j 2
k i , j 0
• Complexity O(n2k2)
FFT Implementation
1
d I , P x , y
2
2
E 2 I x, y P
k
k 1
I 2
x i , y j P 2
i, j 2 I x i, y j Pi, j
i , j 0
Naïve FFT
Time Complexity O(n 2 k 2 ) O(n 2 log n)
Space n2 n2
Integer Arithmetic Yes No
Run time for 16×16 .Sec 1.33 .Sec 3.5
Run time for 32×32 .Sec 4.86 .Sec 3.5
Run time for 64×64 .Sec 31.30 .Sec 3.5
7
x 10
1.5
0.5
0
Normalized Cross Correlation
• NCC:
– A similarity measure, based on a normalized cross-
correlation function.
– Maps two given images to [0,1] (absolute value).
– Measures the angle between vectors Ix,y and P
– Invariant to intensity scale and offset.
d NC I , P
I x, y I 1 P P1
x, y
I x , y I 1 P P1
Efficient Implementation
• Note that X X 1 Y Y 1 X Y nXY
• Thus, d NCI , P
I I 1 P P1
x, y x, y
x, y
I x , y I x , y 1 P P1
I x, y P k 2 I x, y P
I x, y I x, y k 2 2
I x ,
y P P k 2 2
P
• The above expression can be implemented efficiently using 3
convolutions.
7
x 10
1.5
2
1.5
1
0.5
0.5
0 0
10 1.2
50 50
9
1
8
40 40
7
0.8
30 6 30
5 0.6
20 4 20
0.4
3
10 10
2
0.2
1
10 20 30 40 50 60 70 10 20 30 40 50 60 70
•signal reception
•FFT
•indices, coordinates
•File formats
•DICOM – 3D positions
•window levels
16 bits are not enough precision
• ~16 bit analogue to digital converter
– integers 0 – 65535.
• True dynamic range is higher (variable
attenuators in receiver chain).
• Complex FFT and other processing.
• Use “intensity” image (floating point values),
rather than indexed or rgb.
– avoid read/writing intermediate files in tiff, gif.
FAST Fourier Transform Convention
FFT on 2D k-space
k-space FFT
FFT Recipe
1 shift
2 FFT
3 unshift
FFT other tips
• 1/N scaling between forward and reverse.
• Lack of convention for forward/reverse.
• Don’t 3D FFT multi-slice data.
• Beware of indices and the location of DC.
0
N/2 + 1
N/2
Vertical axis reflection
Care mapping:
• spatial
transformations
• k-space
frequencies
2D data in memory and files
2D data stored sequentially in 1D memory/file
ImagePositionPatient +z Head
(x,y,z) r
centre of top-left pixel
+y Posterior
ImageOrientationPatient
(rx, ry, rz, cx, cy, cz) c
image row and column directions
+x Patient Left
Example Example
•restrict FOV
•surf command
•vertices specified
•no edge color
}?
(0,0)
(1,1)
(0.5,0.5)
same image
Window levels
•Alarming differences in gamma
• CRT, LCD
• Sun, Mac, PC.
• printer, toner level.
• projector, room brightness.
•Fix lower range at 0, adjust upper based on
inspection (e.g. exclude fat). Guess gamma.
Present with a colour bar.
•Future: support for .png gamma correction.
Misc.
• In subtraction images, beware of negative values
wrapping round the integer range.
• signed vs. unsigned integers
• MR data is complex: transpose, complex conjugate
and Hermitian transpose are not the same.
• http://www.itk.org
– software
– test data (BrainWeb, Visible Human)
– software links (Image Magick, MRIConvert).
misc. (cont)
Allan M. Cormack
Godfrey N. Hounsfield
Tomography: Reconstruction from Projection
1
f(x,y)
2
Projection & Sinogram
f(x,y)
t
X-rays Sinogram
CT Image & Its Sinogram
1 1
x u
f(x,y)
= [ f(x,y)dy] e -2piux
dx
v
F(u,v)
u
THANK YOU!