Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Unit-2.1

The document discusses spatial processing techniques for image enhancement, focusing on intensity transformation and spatial filtering methods. It covers various intensity transformation functions, histogram equalization, and local histogram processing, as well as smoothing and sharpening filters. The content emphasizes the importance of these techniques in improving image quality and visual appearance.

Uploaded by

aamrit.krishna
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Unit-2.1

The document discusses spatial processing techniques for image enhancement, focusing on intensity transformation and spatial filtering methods. It covers various intensity transformation functions, histogram equalization, and local histogram processing, as well as smoothing and sharpening filters. The content emphasizes the importance of these techniques in improving image quality and visual appearance.

Uploaded by

aamrit.krishna
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

-4-

why spatial processing

http://flickr.com/photos/alliwalk/3284897415/
-5-

roadmap for today


„ Application

„ Method
f ⎯T⎯
⎯→ g = TΝ ( f )
N (.)

f ( x, y ) , 1 ≤ x ≤ M ,1 ≤ y ≤ N g ( x, y ) , 1 ≤ x ≤ M ,1 ≤ y ≤ N
TN (.) : Spatial operator defined on a neighborhood N of a given pixel

N 0 ( x, y ) N 4 ( x, y ) N 8 ( x, y )

point processing mask/kernel


processing
-6-

outline
„ What and why
„ Spatial domain processing for image
enhancement

„ Intensity Transformation
„ Spatial Filtering
-7-

intensity transformation / point operation


„ Map a given gray or color level u to a
new level v

v
„ Memory-less, direction-less operation

output gray level


„ output at (x, y) only depend on the input
intensity at the same point
„ Pixels of the same intensity gets the same
transformation
„ Does not bring in new information, may
cause loss of information input gray level u

„ But can improve visual appearance or


make features easier to detect
-8-

intensity transformation / point operation


„ Two examples we already saw
Color space transformation
Scalar quantization
-9-

image negatives

the appearance of
photographic
negatives

„ Enhance white or
gray detail on dark
regions, esp. when
black areas are
dominant in size
-10-

basic intensity transform functions

„ monotonic, reversible
„ compress or stretch certain range of gray-levels
-11-

log transform

lena

stretch:
FFT(lena) u ∈ [0, .5] Æ
v ∈ [0, .59]
compress:
im = imread(‘lena.png’) u ∈ [.5, 1] Æ
a = abs(fftshift(fft2(double(im)))); v ∈ [.59, 1]
c = log(1+double(im)); c = range_normalize(c);
b = log(1+a); b=b/max(b(:));
-12-
-13-

power-law transformation

„ power-law response
functions in practice
„ CRT Intensity-to-voltage
function has
γ ≈ 1.8~2.5
„ Camera capturing distortion
with γc = 1.0-1.7
„ Similar device curves in
scanners, printers, …

„ power-law transformations are also useful for


general purpose contrast manipulation
-14-

gamma correction
„ make linear input appear linear on displays
„ method: calibration pattern + interactive adjustment

example calibration chart


-15-

effect of gamma on consumer photos


2.2 1/2.2
L0 L0 L0
-16-

what gamma to use?

γ >1
γ <1
?
-17-

more intensity transform


„ log, gamma … closed-form functions on [0,1]
„ can be more flexible

contrast stretching
-18-

intensity slicing
-19-

image bit-planes
-20-

slicing bitplanes
„ Depend on relative importance of bits
„ How much to slice depend on image content
„ Useful in image compression, e.g. JPEG2000
-21-

outline
„ What and why
„ Image enhancement
„ Spatial domain processing
„ Intensity Transformation
„ Intensity transformation functions (negative, log,
gamma), intensity and bit-place slicing, contrast
stretching
„ Histograms: equalization, matching, local
processing
„ Spatial Filtering
„ Filtering basics, smoothing filters, sharpening
filters, unsharp masking, laplacian
„ Combining spatial operations
-22-

gray-level image histogram


„ Represents the relative frequency of occurrence of the
various gray levels in the image
„ For each gray level, count the number of pixels having that level
„ Can group nearby levels to form a big bin & count #pixels in it
-23-

interpretations of histogram
„ if pixel values are i.i.d random
variables Æ histogram is an
estimate of the probability
distribution of the r.v.
„ “unbalanced” histograms do
not fully utilize the dynamic
range
„ Low contrast image: narrow
luminance range
„ Under-exposed image:
concentrating on the dark side
„ Over-exposed image:
concentrating on the bright
side
„ “balanced” histogram gives
more pleasant look and reveals
rich details
-24-

contrast stretching
Stretch the over-concentrated gray-levels
Piece-wise linear function, where the slope in the
stretching region is greater than 1.

β = T (α )

L-1
β2 s3

s2

β1 s1

0 α1 α 2 L-1 α
-25-

… in practice

„ intuition about a “good” image:


„ a “uniform” histogram spanning a large variety of gray tones
„ can we figure out a stretching function automatically?
-26-

histogram equalization
„ goal: map the each luminance level to a new value such that the
output image has approximately uniform distribution of gray levels
„ two desired properties
„ monotonic (non-decreasing) function: no value reversals
„ [0,1]Æ[0,1] : the output range being the same as the input range

pdf

1 1
cdf

o 1 o 1
-27-

histogram equalization
„ make
1

„ show that v follows uniform distribution, i.e.

o 1
-28-

implementing histogram equalization


u v v’
v = ∑ pu ( xi ) Rounding or
xi ≤u Uniform
quantization
pu(xi)

compute n( xi )
pu ( xi ) = L −1
for i = 0, ..., L - 1
histogram
∑ n( x )
i =0
i

u „ Only depend on the input


equalize v = ( L − 1) ∑ pu ( xi ) image histogram
xi = 0
L −1 u „ Fast to implement
or v= ∑ n( xi ) „ For u in discrete prob.
MN xi =0 distribution, the output v
round the will be approximately
output v' = round (v) uniform
-29-

a toy example
u
v = ( L − 1) ∑ pu ( xi )
xi = 0
-30-

a toy example

1.33 1.33 1
1.75 3.08 3
1.47 4.55 5
1.02 5.67 6
0.56 6.23 6
0.42 6.65 7
0.21 6.86 7
0.14 7.00 7
-31-

histogram equalization example


-32-

contrast-stretching vs. histogram equalization


v
γ
output gray level

α
a b
o input gray level u

„ function form
„ reversible? loss of information?
„ input/output?
„ automatic/interactive?
-33-

histogram matching
„ Histogram matching/specification
„ Want output v with specified p.d.f. pV(v)

„ Use a uniformly distributed random vairable


W as an intermediate step
„ W = FU(u) = FV(v) Æ V = F-1V (FU(u) )
„ Approximation in the intermediate step
needed for discrete r.v.
„ W1 = FU(u) , W2 = FV(v) Æ
take v s.t. its w2 is equal to or just above w1
-34-

histogram matching example

Histogram
equalized
-35-

local histogram processing


„ problem: global spatial processing not always desirable
„ solution: apply point-operations to a pixel
neighborhood with a sliding window
-36-

histogram equalization not always desirable


-37-

outline
„ What and why
„ Image enhancement
„ Spatial domain processing
„ Intensity Transformation
„ Intensity transformation functions (negative, log,
gamma), intensity and bit-place slicing, contrast
stretching
„ Histograms: equalization, matching, local
processing
„ Spatial Filtering
„ Filtering basics, smoothing filters, sharpening
filters, unsharp masking, laplacian
„ Combining spatial operations (sec. 3.7)
-38-

spatial filtering in image neighborhoods


-39-

kernel operator / filter masks


TN (.) = w(.)

f Spatial g
Filtering

kernel
a b
g (m, n) = ∑ ∑ w(i, j ) f (m + i, n + j )
i =− a j =−b

1≤ m ≤ M
1≤ n ≤ N
-40-

smoothing: image averaging

smoothing
operator

Low-pass filter, leads to


softened edges
-41-

spatial averaging can suppress noise


image with iid noise y(m,n) = x(m,n) + N(m,n)
UMCP ENEE408G Slides (created by M.Wu & R.Liu © 2002)

„ averaging
v(m,n) = (1/Nw) Σ x(m-k, n-l) + (1/Nw) Σ N(m-k, n-l)
„ Nw: number of pixels in the averaging window
„ Noise variance reduced by a factor of Nw
„ SNR improved by a factor of Nw
„ Window size is limited to avoid excessive blurring
-42-
smoothing operator of different sizes

original 3x3

5x5 9x9

15x15 35x35
-43-

directional smoothing
Problems with simple spatial averaging mask
UMCP ENEE408G Slides (created by M.Wu & R.Liu © 2002)

„
„ Edges get blurred
„ Improvement θ
„ Restrict smoothing to along edge direction
„ Avoid filtering across edges Wθ

„ Directional smoothing
„ Compute spatial average along several directions
„ Take the result from the direction giving the smallest changes
before & after filtering

„ Other solutions
„ Use more explicit edge detection and adapt filtering accordingly
-44-

non-linear smoothing operator


„ Median filtering
„ median value ξ over a small window of size Nw

„ nonlinear
„ median{ x(m) + y(m) } ≠ median{x(m)} + median{y(m)}
„ odd window size is commonly used
„ 3x3, 5x5, 7x7
„ 5-pixel “+”-shaped window
„ for even-sized windows take the average of two
middle values as output
„ Other order statistics: min, max, x-percentile …
-45-

median filter example


„ Median filtering
„ resilient to statistical outliers
„ incurs less blurring
„ simple to implement

iid noise
more at lecture 7, “image restoration”
-46-

image derivative and sharpening


-47-

edge and the first derivative


„ Edge: pixel locations of abrupt luminance
change

„ Spatial luminance gradient vector


„ a vector consists of partial derivatives along two
orthogonal directions
„ gradient gives the direction with highest rate of
luminance changes
„ Representing edge: edge intensity + directions
„ Detection Methods
„ prepare edge examples (templates) of different
intensities and directions, then find the best match
„ measure transitions along 2 orthogonal directions
-48-

edge detection operators


Image gradient:

⎡ ∂f ⎤
⎡Gx ⎤ ⎢ ∂x ⎥
∇f = ⎢ ⎥ = ⎢ ∂f ⎥
⎣G y ⎦ ⎢ ⎥
⎢⎣ ∂y ⎥⎦
∇f ≈ G x + G y

Robert’s
operator

Sobel’s
operator
-49-

edge detection examples

Roberts

Sobel

http://flickr.com/photos/reneemarie11/97326485
http://flickr.com/photos/valkyrie2112/2829322895
-50-

second derivative in 2D

Image Laplacian:
-51-

laplacian of roman ruins

http://flickr.com/photos/starfish235/388557119/
-52-

unsharp masking
„ Unsharp masking is an image manipulation technique for
increasing the apparent sharpness of photographic images.
„ The "unsharp" of the name derives from the fact that the technique
uses a blurred, or "unsharp", positive to create a "mask" of the
original image. The unsharped mask is then combined with the
negative, creating a resulting image sharper than the original.

„ Steps
„ Blur the image
„ Subtract the blurred
version from the original
(this is called the mask)
„ Add the “mask” to the
original
-53-
high-boost filtering

Avg.

-
+

+ f hb ( x, y ) = Af ( x, y ) − f lp ( x, y )
Unsharp mask:
high-boost with A=1
-54-

unsharp mask example


-55-

unsharp mask example

http://flickr.com/photos/dpgnashua/2274968238/
-56-

summary
„ Spatial transformation and filtering are popular
methods for image enhancement
„ Intensity Transformation
„ Intensity transformation functions (negative, log,
gamma), intensity and bit-place slicing, contrast
stretching
„ Histograms: equalization, matching, local processing
„ Spatial Filtering
„ smoothing filters, sharpening filters, unsharp masking,
laplacian
„ Combining spatial operations (sec. 3.7)
-57-

sharpen !

http://flickr.com/photos/t_schnitzlein/87607390/
-58-

You might also like