0% found this document useful (0 votes)
9 views16 pages

UCSE715 - Slide 4

Uploaded by

u21cse1034
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)
9 views16 pages

UCSE715 - Slide 4

Uploaded by

u21cse1034
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/ 16

19-08-2024

Histogram Matching
Histogram matching (histogram specification)
— generate a processed image that has a specified histogram
Let p r ( r ) and p z ( z ) denote the continous probability
density functions of the variables r and z . p z ( z ) is the
specified probability density function.
Let s be the random variable with the prob ability
r
s  T ( r )  ( L  1)  p r ( w ) dw
0

Define a random variable z with the probability


z
G ( z )  ( L  1)  p z (t ) dt  s
0

Histogram Matching
r
s  T ( r )  ( L  1)  p r ( w ) dw
0
z
G ( z )  ( L  1)  p z (t ) dt  s
0

z  G 1 ( s )  G 1 T (r ) 

1
19-08-2024

Histogram Matching: Procedure

► Obtain pr(r) from the input image and then obtain the values of s
r
s  ( L  1)  pr ( w)dw
0

► Use the specified PDF and obtain the transformation function G(z)
z
G ( z )  ( L  1)  pz (t ) dt  s
0

► Mapping from s to z

z  G 1 ( s )

Histogram Matching: Example

Assuming continuous intensity values, suppose that an image has


the intensity PDF
 2r
 , for 0  r  L -1
pr (r )   ( L  1) 2
 0, otherwise

Find the transformation function that will produce an image
whose intensity PDF is
 3z 2
 , for 0  z  ( L -1)
pz ( z )   ( L  1)3
 0, otherwise

2
19-08-2024

Histogram Matching: Example

Find the histogram equalization transformation for the input image


2
r r 2w r
s  T (r )  ( L  1)  pr (w)dw  ( L  1)  dw 
0 0 ( L  1) 2
L 1

Find the histogram equalization transformation for the specified histogram

z z 3t 2 z3
G ( z )  ( L  1)  pz (t )dt  ( L  1)  dt  s
0 0 ( L  1)3 ( L  1)2
The transformation function
1/3
1/3  2 r
2
 1/3
z  ( L  1) s 
2
  ( L  1)    ( L  1)r 2 
 L  1

Histogram Matching: Discrete Cases

► Obtain pr(rj) from the input image and then obtain the values of
sk, round the value to the integer range [0, L-1].
k
( L  1) k
sk  T (rk )  ( L  1) pr ( rj )   nj
j 0 MN j 0
► Use the specified PDF and obtain the transformation function
G(zq), round the value to the integer range [0, L-1].
q
G ( zq )  ( L  1) pz ( zi )  sk
i 0

► Mapping from sk to zq
zq  G 1 ( sk )

3
19-08-2024

Example: Histogram Matching


Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096)
has the intensity distribution shown in the following table (on the
left). Get the histogram transformation function and make the output
image with the specified histogram, listed in the table on the right.

Example: Histogram Matching

Obtain the scaled histogram-equalized values,

s0  1, s1  3, s2  5, s3  6, s4  7,
s5  7, s6  7, s7  7.
Compute all the values of the transformation function G,
0
G ( z0 )  7 pz ( z j )  0.00  0
j 0

G ( z1 )  0.00 0 G ( z2 )  0.00  0
G ( z3 )  1.05 1 G ( z4 )  2.45  2
G ( z5 )  4.55  5 G ( z6 )  5.95  6
G ( z7 )  7.00 7

4
19-08-2024

Example: Histogram Matching

Example: Histogram Matching

Obtain the scaled histogram-equalized values,

s0  1, s1  3, s2  5, s3  6, s4  7,
s5  7, s6  7, s7  7.
Compute all the values of the transformation function G,
0
G ( z0 )  7 pz ( z j )  0.00  0
j 0

G ( z1 )  0.00 0 G ( z2 )  0.00  0
G ( z3 )  1.05  1 s0 G ( z4 )  2.45  2 s1
G ( z5 )  4.55  5 s2 G ( z6 )  5.95  6 s3
G ( z7 )  7.00 7 s4 s5 s6 s7

5
19-08-2024

Example: Histogram Matching

s0  1, s1  3, s2  5, s3  6, s4  7,
s5  7, s6  7, s7  7.

rk
0
1
2
3
4
5
6
7

Example: Histogram Matching


rk  zq
03
1 4
25
36
47
57
67
77

6
19-08-2024

Example: Histogram Matching

Example: Histogram Matching

7
19-08-2024

Example: Histogram Matching

Local Histogram Processing

Define a neighborhood and move its center from pixel to


pixel

At each location, the histogram of the points in the


neighborhood is computed. Either histogram equalization or
histogram specification transformation function is obtained

Map the intensity of the pixel centered in the neighborhood

Move to the next location and repeat the procedure

8
19-08-2024

Local Histogram Processing: Example

Using Histogram Statistics for Image


Enhancement
Average Intensity L 1 M 1 N 1
1
m   ri p( ri ) 
MN
  f ( x, y )
x 0 y 0
i 0
L 1
un (r )   ( ri  m)n p ( ri )
i0

Variance L 1 M 1 N 1
1
  u2 (r )   (ri  m)    f ( x, y )  m 
2 2 2
p( ri ) 
i 0
MN x 0 y 0

9
19-08-2024

Using Histogram Statistics for Image


Enhancement

Local average intensity


L 1
msxy   ri psxy (ri )
i 0

sxy denotes a neighborhood

Local variance
L 1
 2
s xy   ( ri  msxy ) 2 psxy (ri )
i 0

Using Histogram Statistics for Image


Enhancement: Example

 E f ( x, y ), if msxy  k0 mG and k1 G   sxy  k2 G


g ( x, y )  
 f ( x, y ), otherwise

mG : global mean;  G : global standard deviation


k0  0.4; k1  0.02; k2  0.4; E  4

10
19-08-2024

Spatial Filtering

A spatial filter consists of (a) a neighborhood, and (b) a


predefined operation

Linear spatial filtering of an image of size MxN with a filter


of size mxn is given by the expression

a b
g ( x, y )    w( s , t ) f ( x  s , y  t )
s  a t  b

Spatial Filtering

11
19-08-2024

Spatial Correlation

The correlation of a filter w( x, y) of size m  n


with an image f ( x, y ), denoted as w( x, y ) f ( x, y)

a b
w( x, y ) f ( x, y )    w( s, t ) f ( x  s, y  t )
s  a t  b

Spatial Convolution

The convolution of a filter w( x, y ) of size m  n


with an image f ( x, y ), denoted as w( x, y ) f ( x, y)

a b
w( x, y ) f ( x, y )    w( s, t ) f ( x  s, y  t )
s  a t  b

12
19-08-2024

Smoothing Spatial Filters

Smoothing filters are used for blurring and for noise


reduction

Blurring is used in removal of small details and bridging of


small gaps in lines or curves

Smoothing spatial filters include linear filters and nonlinear


filters.

13
19-08-2024

Spatial Smoothing Linear Filters

The general implementation for filtering an M  N image


with a weighted averaging filter of size m  n is given
a b

  w(s, t ) f ( x  s, y  t )
g ( x, y )  s  a t  b
a b

  w( s, t )
s  a t  b

where m  2 a  1, n  2b  1.

Two Smoothing Averaging Filter Masks

14
19-08-2024

Example: Gross Representation of Objects

15
19-08-2024

Order-statistic (Nonlinear) Filters

— Nonlinear

— Based on ordering (ranking) the pixels contained in the


filter mask

— Replacing the value of the center pixel with the value


determined by the ranking result

E.g., median filter, max filter, min filter

Example: Use of Median Filtering for Noise Reduction

16

You might also like