EEM 486 EEM 486: Computer Architecture Lecture 6 Memory Systems and Caches.
EEM 463 Introduction to Image Processing Week 3: Intensity...
Transcript of EEM 463 Introduction to Image Processing Week 3: Intensity...
EEM 463 Introduction to Image Processing
Week 3: Intensity Transformations
Fall 2013
Instructor: Hatice Çınar Akakın, Ph.D.
Anadolu University
Enhancement Domains
• Spatial Domain: image plane itself, direct manipulation of pixels
• Transform domain: process on the transform domain coefficients
( , ) [ ( , )])
( , ) : input image
( , ) : output image
: an operator on defined over
a neighborhood of point ( , )
g x y T f x y
f x y
g x y
T f
x y
Spatial domain
process
Enhanced Images
• For human vision• Evaluation of image quality is a highly subjective process
• No standard for a for a good image definition
• For machine perception• Evaluation of image quality is easier
• Best machine results represents the good image
• Trail and error is necessary to select an appropriate imageenhancement approach.
• e.g. a method that is quite useful for enhancing X-Ray images may not be thebest for satellite images taken in infrared band of EM specytrum.
Intensity Transformation
T : intensity transformation function
s = T( r )
Highercontrast
Two-level(binary) image
Point processşng
• Tree basic gray-level transformation
f’ns.• Linear function: Negative and intensity
transformations
• Logarithmic function: Log snd inverse-log
transformations
• Power-law function: nth power and nth root
transformations
Image Negatives
Image negatives
1s L r
Suitable for enhancing white or gray detail
embedded in dark regions of an image, especially when black area is large.
Same visualcontent
Log Transformations
Log Transformations
log(1 )s c r
• Log curve maps a narrow range of low
graylevels in input image into a wider
range of output levels.
• Expands range of dark image pixels while
shrinking bright range.
• Inverse log expands range of bright image
pixels while shrinking dark range.
Power-Law Transformation
• It is also called Gamma Correction
s cr
1/2.5s r
Cathode ray tube (CRT) devices have an intensity-to-voltage response that is a power function, with exponents varying from approximately 1.8 to 2.5
This darkens the picture.
• Gamma correction is done by
preprocessing the image
before inputting it to the
monitor.
a) Dark MRI. Expand gray level
range for contrast manipulation
γ < 1
(b) γ = 0.6, c=1
(c) γ = 0.4 (best result)
(d) γ = 0.3 (limit of acceptability)
When γ is reduced too much, the
İmage begins to reduce contrast to
the point where it starts to have a
“washed-out” look,especially in
the background
• Washed-out image. • Shrink gray level range
• γ > 1
Piecewise-Linear Transformation Functions
• Pro: can be arbitrarily complex
• Con: specification requires considerably more user input
Contrast Stretching
• Expands the range of intensity levels in an image so that it spans the full intensity range of the recording medium or display device.
Intensity level slicing
Highlights a specific range of intensities
Bit-plane slicing
highlight the contribution made to total image
appearance by specific bits
Originalimage
Histogram Processing
Normalized histogram ( )
: the number of pixels in the image of
size M N with intensity
kk
k
k
np r
MN
n
r
Histogram ( )
is the intensity value
is the number of pixels in the image with intensity
k k
th
k
k k
h r n
r k
n r
Estimate of theprobability of occurrence of intensity level
• Basis for numerous spatial domain processing techniques
• Provides useful image statistics
• Useful for image enhancement, image compression andsegmentation
Components ofhistogram areconcentrated on the low side of the gray scale.
Components ofhistogram areconcentrated on the high side of the gray scale.
Histogram Equalization
• Probability density function (pdf) is wanted to be uniformly ditributed.
( ) 0 1s T r r L
. T(r) is a strictly monotonically increasing function
in the interval 0 -1;
. 0 ( ) -1 for 0 -1.
a
r L
b T r L r L
( ) is continuous and differentiable.T r ( ) ( )s rp s ds p r dr
0
( )( 1) ( )
r
r
ds dT r dL p w dw
dr dr dr
( 1) ( )rL p r
( ) 1( ) ( )
( )( 1) ( ) 1
r r rs
r
p r dr p r p rp s
L p rdsds L
dr
Cumulativedistribution function
(cdf)0( ) ( 1) ( )
r
rs T r L p w dw
Histogram Equalization
0
Discrete values:
( ) ( 1) ( )k
k k r j
j
s T r L p r
0 0
1( 1) k=0,1,..., L-1
k kj
j
j j
n LL n
MN MN
Example: 3-bit image (L=8), 64x64pixels
0
0 0
0
( ) 7 ( ) 7 0.19 1.33r j
j
s T r p r
1
1 1
0
( ) 7 ( ) 7 (0.19 0.25) 3.08r j
j
s T r p r
Tend to spread the histogram of the input image
• intensity levels of the equalized image span a
wider range
• contrast enhancement
Histogram Matching (Specification)
• If uniform distribution is not a good approach• Generate a processed image that has a specified histogram
Let ( ) and ( ) denote the continous probability
density functions of the variables and . ( ) is the
specified probability density function.
Let be the random variable with the prob
r z
z
p r p z
r z p z
s
0
0
ability
( ) ( 1) ( )
Define a random variable with the probability
( ) ( 1) ( )
r
r
z
z
s T r L p w dw
z
G z L p t dt s
0
0
( ) ( 1) ( )
( ) ( 1) ( )
r
r
z
z
s T r L p w dw
G z L p t dt s
1 1( ) ( )z G s G T r
Procedure• Obtain pr(r) from the input image and then obtain the values of s
• Use the specified PDF and obtain the transformation function G(z)
• Mapping from s to z
• Obtain the output image by equalizing the input image. For each pixel withvalue s in the equalized image, perform the inverse mapping to obtainoutput pixels.
0( 1) ( )
r
rs L p w dw
0( ) ( 1) ( )
z
zG z L p t dt s
1( )z G s
pz(z) is given!
Discrete Formulation
• pz(zk): specified pdf
• Tansformation function:
• Mapping:
0 0
( 1)( ) ( 1) ( )
k k
k k r j j
j j
Ls T r L p r n
MN
0
( ) ( 1) ( )q
q z i k
i
G z L p z s
1( )q kz G s
(1): G(z)(2): G-1(z)
• For the details of histogram processing, read Chapter 3.1-3.3
Fundamentals of Spatial Filtering
• Spatial filter: spatial masks, kernels, templates or windows
• Filtering creates a new pixel with coordinates equal to the center of the neighborhood, with value of the result of filtering operation
( , ) ( , ) ( , )a b
s a t b
g x y w s t f x s y t
Spatial Correlation and Convolution
• Correlation is a process of moving a filter mask over the image andcomputing the sum of products at each location
• Convolution has the same mechanics but with a filter rotated by 180°.
Spatial Correlation and Convolution
The convolution of a filter ( , ) of size
with an image ( , ), denoted as ( , ) ( , )
w x y m n
f x y w x y f x y
( , ) ( , ) ( , ) ( , )a b
s a t b
w x y f x y w s t f x s y t
*
Smoothing Spatial Filters
• Output is the average of pixels caontained in the neighborhood of thefilter mask
• Averaging filters or lowpass filters
• Reduce sharp transitions in intensities
• Used for blurring and noise reduction• Blurring removes small details and connects small gaps in lines or curves
• They can be linear or nonlinear filters
The general implementation for filtering an M N image
with a weighted averaging filter of size m n is given
( , ) ( , )
( , )
( , )
where 2 1
a b
s a t b
a b
s a t b
w s t f x s y t
g x y
w s t
m a
, 2 1.n b
Sum of the mask coefficients: constantcomputed only once
• To generate a mxn linear filter, we need to specify mn mask coefficients, selected based on the purpose of the filter
• Example: Spatial filter mask based on a continuous function of two variables, e.g. Gaussian Function:
Note that:
• big mask is used to eliminate small
objects from an image.
• the size of the mask establishes the
relative size of the objects that will be
blended with the background.
- Blur to get gross representation of objects.- Intensity of smaller objects blend with background.- Larger objects become blob-like and easy to detect
Threshold value is chosen to be 25% of the
highest intensity
Order-Statistic (Nonlinear) Filters
• It is based on ordering (ranking) the pixels contained in the filter mask
• Center pixel value is replaced with the value of ranking result• Median filter
• Max filter
• Min filter
Sharpening Spatial Filters
• Objective is to highlight transitions in intensity
• Spatial differentiation enhances the edges and other discontinuities
Foundation
1. The first-order derivative of a one-dimensional function f(x) is the difference
2. The second-order derivative of f(x) as the difference
( 1) ( )f
f x f xx
2
2( 1) ( 1) 2 ( )
ff x f x f x
x
The Laplacian Operator
• Isotropic filter: response independent of the direction of thediscontinuities in the image (rotation invariant)
• Laplacian of a function f(x,y):
• Discrete form:
2 22
2 2
f ff
x y
2
2( 1, ) ( 1, ) 2 ( , )
ff x y f x y f x y
x
2
2( , 1) ( , 1) 2 ( , )
ff x y f x y f x y
y
2 ( 1, ) ( 1, ) ( , 1) ( , 1)
- 4 ( , )
f f x y f x y f x y f x y
f x y
Unsharp masking and Highboost Filtering
• Unsharp masking:• Blur the original image 𝑓(𝑥, 𝑦) 𝑓(𝑥, 𝑦)
• Subtract the blurred image 𝑓(𝑥, 𝑦) from the original image 𝑓(𝑥, 𝑦)mask
𝑔𝑚𝑎𝑠𝑘 = 𝑓 𝑥, 𝑦 − 𝑓(𝑥, 𝑦)
• Add the mask to the original image:
𝑔 𝑥, 𝑦 = 𝑓 𝑥, 𝑦 + 𝑘 ∗ 𝑔𝑚𝑎𝑠𝑘 𝑥, 𝑦 k≥0
k = 1 unsharp maskingk > 1 highboost filtering
Image Sharpening based on First-Order Derivatives
For function ( , ), the gradient of at coordinates ( , )
is defined as
grad( )x
y
f x y f x y
f
g xf f
fg
y
2 2
The of vector , denoted as ( , )
( , ) mag( ) x y
magnitude f M x y
M x y f g g
Gradient Image
( , ) | | | |x yM x y g g
Robert’s cross-gradient operators
Sobel operators
7 8 9 1 2 3
3 6 9 1 4 7
Sobel Operators
( , ) | ( 2 ) ( 2 ) |
| ( 2 ) ( 2 ) |
M x y z z z z z z
z z z z z z
Combining Spatial Enhamement Methods
Calculating the histogram
• %
% reading image from the file
im = imread('C:\Users\user\Documents\Documents\EEM463\Butterfly-yorkshire_rose.jpg');
im1 = double(rgb2gray(im));
% size of the image
[M N]= size(im1);
for k = 0:255
p(k+1) = sum(sum(im1==k));
end
bar(0:255,p);
Normalizing an image
i1 = load('clown');
whos i1
i1
figure;image(X); colormap(map);
mx = max(max(X));
mn = min(min(X));
imN = 255*(X-mn)/(mx-mn);