0% found this document useful (0 votes)
4 views

MIP Lecture 3

The document discusses intensity transformations and spatial filtering techniques in image processing, focusing on methods to enhance images for specific applications. It covers various intensity transformation functions, histogram processing, and the fundamentals of spatial filtering, including smoothing and sharpening filters. Additionally, it addresses the importance of local statistics and the use of fuzzy techniques in image enhancement.

Uploaded by

algoart427
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

MIP Lecture 3

The document discusses intensity transformations and spatial filtering techniques in image processing, focusing on methods to enhance images for specific applications. It covers various intensity transformation functions, histogram processing, and the fundamentals of spatial filtering, including smoothing and sharpening filters. Additionally, it addresses the importance of local statistics and the use of fuzzy techniques in image enhancement.

Uploaded by

algoart427
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

III.

Intensity Transformations
and Spatial Filtering

III. Intensity Transformations and


Spatial Filtering
1. Preview
2. Some basic intensity transformation functions
3. Histogram processing
4. Fundamentals of spatial filtering
5. Smoothing spatial filters
6. Sharpening spatial filters
7. Combining spatial enhancement methods
8. Using fuzzy techniques for intensity
transformations and spatial filtering

1
Preview
• The principal objective of enhancement
– to process an image so that the result is more suitable than the
original image for a specific application.

ex) A method that is quite useful for enhancing X-ray images may
not necessarily be the best approach for enhancing pictures of Mars
transmitted by a space probe.

• The term spatial domain : the image plane itself


– Based on direct manipulation of pixels in an image.
– Frequency domain processing techniques : based on the Fourier
transform of an image.

• There is no general theory of image enhancement.


– When an image is processed for visual interpretation, the viewer is
the ultimate judge of how well a particular method works.

Intensity Transformation Functions


• Single point processing
• s=T(r) r:input pixel value, s:output value
• Look-up table technique
– L LUT (L : # of gray levels, 2N)
L-1
– s=LUT[r]
– Filling LUT with T
Output s
T : identity
(s=r)

0
0 Input r L-1

2
Some Basic Intensity Transformation
Functions
- Image Negatives
• s=L-1-r
• (0,1,2,…254,255)à(255,254,…,1,0)
L-1

T
Output s

0
0 Input r L-1

Log Transformations
• s=c log(1+r)
• Compresses the dynamic range of the image
ex) to visualize Fourier spectra
• to expand the values of dark pixels in an image while
compressing the higher-level values. (and vice versa)
L-1

Output s

0
0 Input r L-1

3
Power-Law (Gamma) Transformation

• s=c rg
• Compresses the dynamic range of the
image
– the exponent is called gamma (g)
– gamma correction
– i.e. CRT monitors have an intensity to
voltage response which is a power-law
with gamma 1.8-2.5
• As in the case of the log transformation,
power-law curves with fractional values of y
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

Gamma Correction
• Useful to compensate for the
non-linear response of monitors

VGA control panel

4
ex) MRI image (surface coil)
and aerial image (washed-out)
g=0.6 g=3.0

g=0.4 g=0.3 g=4.0 g=5.0

reduce contrast (g<1) enhance contrast (g>1)

Piecewise-Linear Transformations
- Contrast Stretching
• Adjust brightness and contrast
• Expand the range of intensity levels

5
Example : CT image
(Window/Level)

Intensity-Level Slicing
• Highlighting a specific range of intensities

6
Histogram Processing
• The number of pixels having dark image

the same gray level


à intensity distribution
light image

• Useful for
– gathering image statistics
– spatial domain (real-time)
processing low-contrast

• How to get the histogram


for (i=0; i<L; i++) hist[i]=0; high-contrast

for (i=0; i<N; i++) hist[r]++;

Example : CT image
The meaningless background should be excluded.

tissue

bone

• Not evenly distributed


• The pixels of the meaningless
background are also included.

7
Histogram Equalization
• s=T(r)
• PDF : pr(r), ps(s)

• Cumulative distribution function


r
s = T (r ) = ( L - 1) ò pr ( w)dw
0

ds dT ( s ) d r
= = ( L - 1) [ ò pr ( w)dw] = ( L - 1) pr (r )
dr dr dr 0
dr 1 1
p s ( s ) = pr ( r ) = pr ( r ) =
ds ( L - 1) pr (r ) L - 1

ps(s) is always a uniform PDF.

• For discrete values, PDF à normalized histogram (divided by the total


number of pixels)
r
s = T (r ) = ( L - 1)å pr ( j ) à Histogram Equalization
j =0

Example
Intensity distribution and histogram for
a 3-bit 64x64 image
r n pr(r)=n/(64x64) s
0 790 0.19 1
1 1023 0.25 3
2 850 0.21 5
3 656 0.16 6
4 329 0.08 6
5 245 0.06 7
6 122 0.03 7
7 81 0.02 7
0
s0 = T (0) = 7å pr ( j ) = 7 pr (0) = 1.33 » 1
j =0
1
s1 = T (1) = 7å pr ( j ) = 7{ pr (0) + pr (1)} = 3.08 » 3
j =0

s2=4.55≈5, s3=5.67≈6, s4=6.23≈6, s5=6.65≈7, s6=6.86≈7, s7=7.00≈7

8
Examples

Each transformation function for


histogram equalization

Example : CT image

9
Histogram Matching (Specification)
• Given histogram pz(z)
r
• s = T (r ) = ( L - 1) ò pr ( w)dw: histogram-equalized
0
z
s = G ( z ) = ( L - 1) ò p z ( w)dw
0

z = G -1[T (r )] = G -1 ( s )

r n pr(r) s z pz(z) s=G(z) r s z


0 790 0.19 1 0 0.00 0 0 1 3
1 1023 0.25 3 1 0.00 0 1 3 4
2 850 0.21 5 2 0.00 0 2 5 5
3 656 0.16 6 3 0.15 1 3 6 6
4 329 0.08 6 4 0.20 2 4 6 6
5 245 0.06 7 5 0.30 5 5 7 7
6 122 0.03 7 6 0.20 6 6 7 7
7 81 0.02 7 7 0.15 7 7 7 7

Using Histogram Statistics


• Mean : average gray level
L -1
m = å r p(r ) i i
i =0

M -1 N -1
1
m=
MN
åå f ( x, y)
x =0 y =0

• Nth moment of r
L -1
m n (r ) = å (ri - m) n p (ri )
i =0

• Variance : average contrast, texturing, activity


L -1
2 2
m ( r ) = s = å ( r - m) p ( r )
2 r i i
i =0
M -1 N -1
1
s2 = åå [ f ( x, y) - m] 2

MN x =0 y =0

• Local statistics
– Good measures for spatially-adaptive processing

10
Example of Local Processing

• Low and high contrast areas


• Enhance low contrast areas
• Local region ß 3x3 window
g ( x, y ) = E × f ( x, y ) if ms xy £ k 0 mG AND k1s G £ s s xy £ k 2s G
f ( x, y ) otherwise

Homework #2
• Enhance the contrast of the CT image
1) Apply global histogram equalization.
2) Apply the same algorithm as the example.
- Choose appropriate E, k0, k1, k2
3) Compare both results.

☞ Do not include background pixels out of the circle

11
Fundamentals of Spatial Filtering
• Spatial filtering ⇔ Frequency domain filtering
• filtering operations that are performed directly
on the pixels of an image
• Operation between a neighborhood
• Define a 2D filter with the following properties
– linear
– Space-invariant
– finite impulse response (FIR) ß Convolution

Linear Spatial Filter


a b
g ( x, y ) = å å w( s, t ) f ( x - s, y - t )
s =- a t =-b

à Sliding and sum-of-product

The process consists simply of


moving the filter mask from point to
point in an image.

a=1, b=1 for 3x3 filter mask

12
Linear Convolution
• Space-invariant linear system

input f(x,y) Impulse response output g(x,y)=h(x,y)*f(x,y)


h(x,y)

• h(x,y) : impulse response, point spread function à resolution of the system


ex) if h(x,y) =d(x,y), g(x,y)=f(x,y)
• Convolution
- Replace each pixel with r·h(x,y) * =
- Sliding and sum-of-product
• m x n convolution (m=2a+1, n=2b+1)
g ( x, y ) = w( x, y ) * f ( x, y ) * =
a b
= å å w( s, t ) f ( x - s, y - t )
s =- a t =-b

w(x,y) : m × n convolution filter(mask, kernel)


à filter design * =

Remarks
• Filtering is linear because each output pixel value is computed as a
linear combination of a set of input pixel values.
• Filtering is space invariant because filter coefficients are independent
on the point of application (x, y).
• The output has size (M+m-1)×(N+n-1) samples, but practically
(M×N)
• The sum of filter coefficients?
– Normalization
– Output : overflow, underflow
• Computational complexity ∝ M×N×m×n
– why 3×3 convolution is popular
• The borders of the image?
– exclude borders à effective output size (M-a)×(N-b)
– add padding to the input image with average gray level
– bypass (replace with input pixels)
– fill zeros

13
Smoothing Spatial Filters
• Blurring to remove small details and extract a large
object
• Noise reduction
• Low pass filter – remove high frequency components
• The most simple smoothing filter : Averaging filter
1 1 1 1 1
1 1 1 1 1 1 1 1
1/9 × 1 1 1 1/25 × 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1
• Weighted average
1 2 1
1/16 × 2 4 2
1 2 1

Weighted Average

1 1 1 - 9 pixel averaging (K=1)


1
´
1 K 1 K+8 - K↑ à SNR↓, Resolution↑
1 1 1

K=4 K=1

14
Window Size Effect of Average Filter
3x3

5x5 9x9

15x15 35x35

Removal of small details

Image of size 528x485 15 x 15 averaged Result of thresholding


(Hubble Space Telescope)

15
Order-Statistic (Nonlinear) Filters
• Based on ordering the pixels
• ex) maximum, minimum, median filters
• Nonlinear filter
• Median filter
– Quite popular
– Excellent noise-reduction capabilities with less blurring (edge-
preserving filter)
– In particular, effective to remove impulse noise (salt-and-
pepper)
– Remove defective pixels
3
4
5, 4, 5.5, 100, 6, 7, 8, 7, 7.5
2

1
4, 5, 5.5, 6, 7, 7, 7.5, 8, 100 1 0.67
0.5
Median = 7
3x3 median 3x3 averaging
Average = 16.7

Examples

Salt and pepper averaging median


noise

16
Blurring Filter and Median Filter

x1 x2 x3 x10 x∞

Sharpening Spatial Filters


• Highlighting intensity transitions
– Enhance intensity discontinuity (edges and noise)
– Deemphasize areas with slowly varying intensities
• Edge detection

• Sharpening ß spatial differentiation


(Averaging ß integration)

• Digital derivatives à differences


- The 1st-order derivative
∂f(x,y)/∂x=f(x+1,y)-f(x,y)

- The 2nd-order derivative


∂2f(x,y)/∂x2={f(x+1,y)-f(x,y)}-{f(x,y)-f(x-1,y)}=f(x+1,y)+f(x-1,y)-2f(x,y)

17
The 1st and 2nd Order Derivatives

- 1st-order derivatives à thicker edges

- 2nd-order derivatives à a stronger response


to fine detail à better for enhancement

-1st-order derivatives à a stronger response


to a gray-level step

-2nd-order derivatives à a double response


at step changes in gray level

The Laplacian – The 2nd Derivative


• ∇2f=∂2f(x,y)/∂x2+∂2f(x,y)/∂y2
∂2f(x,y)/∂x2=f(x+1,y)+f(x-1,y)-2f(x,y)
∂2f(x,y)/∂y2=f(x,y+1)+f(x,y-1)-2f(x,y)
2
∇ f=f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)-4f(x,y)

• Laplacian Sharpening : g(x,y)=f(x,y)+c[∇2f]


• Remark : Negative value à clipping or scaling

18
Examples of the Laplacian Operator

clipping scaling
0 -1 0

-1 4 -1

0 -1 0

c=1 c=1
0 -1 0 -1 -1 -1

-1 5 -1 -1 9 -1

0 -1 0 -1 -1 -1

g(x,y)=f(x,y)+∇2f=(1+∇2)f(x,y)

Unsharp Masking and Highboost Filtering


• Unsharp masking
1) Blur
2) Subtract the blurred image from the original à unsharp mask
g mask ( x, y ) = f ( x, y ) - f ( x, y )
3) Add the mask to the original
g ( x, y ) = f ( x, y ) + k × g mask ( x, y )

• k>1 : Highboost filtering

5x5 Gaussian smoothing


filter (σ=3)

k=1

Highboost
(k=4.5)

19
Gradient – The 1st Derivative
• Gradient é ¶f ù
é g x ù ê ¶x ú
Ñf º grad ( f ) º ê ú = ê ¶f ú
ëg y û ê ú
êë ¶y úû
• Gradient image
M ( x, y ) =| Ñf |= g x2 + g y2 » | g x | + | g y | z1 z2 z3

z4 z5 z6
• The simplest approximation
gx=z6-z5, gy=z8-z5 z7 z8 z9

• Roberts cross-gradient operator


gx=z9-z5, gy=z8-z6
-1 0 0 -1
M(x,y)=[gx2+gy2]1/2=|gx|+|gy|
0 1 1 0

Sobel Operators
-1 0 1 -1 -2 -1
• gx=f(x,y)* -2 0 2 gy=f(x,y)* 0 0 0

-1 0 1 1 2 1

-1 0 1

-1 0 1 -1 0 1

-1 0 1

• M(x,y)=|gx|+|gy|

• Some smoothing by giving more importance to the center point


• Sum of coefficients = 0 à 0 in flat areas of constant intensity
• The most popular edge-detector
• Enhance defects and eliminate slowly changing background features
à preprocessing for automatic inspection

20
Example

Optical image of contact lens and Sobel gradient


(note defects)

The edge defects are quite visible, but with the added advantage that
constant or slowly varying shades of gray have been eliminated thus
simplifying considerably the computational task required for
automated inspection. à preprocessing step

Combining Spatial Enhancement Methods

5.④ smoothed with


1.original (SPECT) 2.Laplacian 5x5 averaging 6.③x⑤

3.①+② 4.Sobel 7.①+⑥ (sharpened) 8. power-law of ⑦

21
Fuzzy Set
• “Crisp” set : 1 or 0, true or false (bi-valued
Boolean logic)
• Membership functions
– Set of “young” people

young or not. Degrees of “youngness”


How about 20 years and 1 sec? young, relatively young, 50% young, not
so young, not young
à “Fuzzy” statements

Several Definitions

A∪B A∩B

22
Examples of Membership Functions

Using Fuzzy Sets for Intensity


Transformations
• Contrast enhancement
- IF a pixel is dark, THEN make it darker
- IF a pixel is gray, THEN make it gray
- IF a pixel is bright, THEN make it brighter

• Defuzzification (center of gravity) : obtain a crisp output from a fuzzy set

m dark ( z0 ) ´ vd + m gray ( z0 ) ´ v g + mbright ( z0 ) ´ vb


v0 =
m dark ( z0 ) + m gray ( z0 ) + mbright ( z0 )

• vd=0(black), vg=127(mid gray), vb=255(white)

23
Example

Using Fuzzy Sets for Spatial Filtering


• Boundary extraction
If a pixel belongs to a uniform region, then make it white;
else make it black
• di=zi-z5
IF d2 is zero AND d6 is zero, THEN z5 is white
IF d6 is zero AND d8 is zero, THEN z5 is white
IF d8 is zero AND d4 is zero, THEN z5 is white
IF d4 is zero AND d2 is zero, THEN z5 is white
ELSE z5 is black

24
Example

Does Bush have a device


under his Jacket?

See big bulge with image


enhancement.

Bush is wired! Secret earpiece


tells him what to say!

25
Homework #3
• Improve the SNR of the noisy MR image below by use of a 5x5
averaging filter
• Preserve edges as much as possible
– Design a simple adaptive filter (space-variant)
• Get an edge image of the 2nd noisy image using the Sobel mask
• Change the filter coefficient K according to the edge strength
– K=1 for a flat area (no edge)
– Larger K for a strong edge
• Compare the result with the original images with/without noise

1 1 1 1 1
1 1 1 1 1
1/(K+24) × 1 1 K 1 1
1 1 1 1 1
K=1 1 1 1 1 1
Image without noise Image with noise
(for comparison)

26

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy